who9vy
who9vy

Reputation: 1101

Boost graph - after vertex removal, vertex still exists

Probably, it is a bug in the graph library of boost but perhaps you can help me out.

As shown in a previous question there is a problem with removing a vertex from a graph and adding it back again.

My problem is slightly different. I have a boost::labeled_graph using an object pointer as label. Let anObject be a pointer to a particular object and let aGraph be a boost::labeled_graph. Then the following code is executed:

clear_vertex_by_label(anObject, aGraph);
aGraph.remove_vertex(anObject);

Vertex v = aGraph.vertex(anObject);

I would have expected an exception but instead v seems to be a vertex in aGraph. Now the following problem occurs (and I think it only occurs with boost::labeled_graph):

When I execute the following code:

clear_vertex_by_label(anObject, aGraph);
aGraph.remove_vertex(anObject);

Vertex v = aGraph.add_vertex(aSecondObject);

Vertex v2 = aGraph.vertex(anObject);
Vertex v3 = aGraph.vertex(aSecondObject);

After execution of this code v == v2 == v3 and that cannot be correct.

Has got anyone an idea how to fix this problem? Is there a possibility to remove a label completely from the graph? I think that the label still exists and it still "points" to the same vertex node although the vertex itself is not the same anymore (or even if it does not exist).

Thanks!

Upvotes: 3

Views: 488

Answers (1)

Adam Romanek
Adam Romanek

Reputation: 1879

I might be wrong but I guess this is caused by the same bug that I described in an answer to the previous question you refer to.

The vertex itself does not exist anymore but its associated vertex descriptor does as the implementation does not remove it from labeled_graph's internal map.

If I'm correct then the problem is a result of a bug in the implementation of boost::labeled_graph. It's present both in Boost 1.54.0 and 1.55.0 (latest release).

See the bug report for a patch that might solve this issue for you.

Upvotes: 2

Related Questions