Boost graphs - Cannot use add_edge()

So.. I found out that the boost is capable of creating graphs.
In my case i have a custom vertex, which i want to use. which i think messes up with the boost structure.

Here is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class Vertex {
    int x;
    int y;
    char element;
    int num_Edges;
public:
    Vertex();
    Vertex(int x, int y, char element);
    int getX(){
        return x;
    }
    int getY(){
        return y;
    }
    char getElement()
    {
        return element;
    }
    int getNumEdges(){
        return num_Edges;
    }
};

using grapht = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
    Vertex>;
    
    vector<pair<Vertex, Vertex>> edges;
    int col = map.getCol();
    int row = map.getRow();
    for(int y = 0; y < col; y++){
        for (int x = 0; x < row; x++) {
            char temp = map.getChar(x, y);
            if (isitTrue(temp)) {
                cout << "possible vertex found" << endl;
                //boost::add_vertex(Vertex(x, y, temp),grapht);
                if (x < row)
                {
                    if (isitTrue(map.getChar(x+1,y))) {
                        cout << "edge found - 1" << endl;
                        edges.emplace_back(Vertex(x, y,temp),Vertex(x+1, y,map.getChar(x+1, y)));
                    }
                }
                if (x >= 0)
                {
                    if (isitTrue(map.getChar(x-1,y))) {
                        cout << "edge found - 2" << endl;
                        edges.emplace_back(Vertex(x, y,temp),Vertex(x-1, y,map.getChar(x-1, y)));
                    }
                    
                }
                if (y >= 0)
                {
                    if (isitTrue(map.getChar(x,y-1))) {
                        cout << "edge found - 3" << endl;
                        edges.emplace_back(Vertex(x, y,temp),Vertex(x, y-1,map.getChar(x, y-1)));
                    }
                    
                }
                if (y < col)
                {
                    if (isitTrue(map.getChar(x,y+1))) {
                        cout << "edge found - 4" << endl;
                        edges.emplace_back(Vertex(x, y,temp),Vertex(x, y+1,map.getChar(x, y+1)));
                    }
                }
            }
        }
    }
    cout << edges.size() << endl;
    grapht graph(edges.begin(), edges.end(),edges.size());
    std::cout << "Hello, World!\n";


You shouldn't care about map, it just a function handling a map.

My problem when i call
1
2
    grapht graph(edges.begin(), edges.end(),edges.size());
 
I get the error message "No matching function to call to add_edge"

which must be because of my vertex declaration.. but how should I then use it?
Last edited on
1
2
vector<pair<Vertex, Vertex>> edges;
vector<pair<int, int>> edges;
Edge is represented as pair of numbers which represent vertices in order of inserting in the graph.
Topic archived. No new replies allowed.