boost - code crashes when trying to add a vertex to existing graph -


i trying simple task of adding vertex existing graph, code crashes:

typedef adjacency_matrix<undirecteds> ugraph; graph_traits<ugraph>::vertex_descriptor u;  ugraph g(2);  int numofcomponents = 0; int numofvertices = 0;  numofvertices = num_vertices(g); //numofvertices = 2 vector<int> component(numofvertices); numofcomponents = connected_components(g, &component[0]); //numofcomponents = 2 

so far seems logical- 2 vertices, not connected, there 2 connected components.

now, when try add vertex:

u = vertex(3, g); //u=3 add_vertex(u,g); // <--- crashes here 

am missing something? how can add vertex existing graph? removing? see 1 less vertex after command remove_vertex(id)?

also, possible add vertex id of 100 instead of id 3 (not continues id number..)?

thanks.

it's matrix. has fixed size (nxn n number of vertices).

you cannot "address" third vertex doesn't exist in 2x2 matrix.

add_edge defined mutablegraph, mutablepropertygraph (with properties). adjacency_matrix doesn't model concepts

http://www.boost.org/doc/libs/1_58_0/libs/graph/doc/graph_concepts.html


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -