views:

30

answers:

1

I have a Boost Graph with VertexList=vecS.

typedef adjacency_list <listS, vecS, undirectedS, TrackInformation, LinkInformation> TracksConnectionGraph;

Now I want to iterate through my vertices and remove those that have a specific property. How can I do this?

The problem is whenever I call remove_vertex, the iterator to the vertices in the graph along with the vertex descriptors are invalidated.

+1  A: 

I don't think it is possible (in a reasonable time) with vecS as a template parameter. Look what Boost documentation says:

If the VertexList template parameter of the adjacency_list was vecS, then all vertex descriptors, edge descriptors, and iterators for the graph are invalidated by this operation. <...> If you need to make frequent use of the remove_vertex() function the listS selector is a much better choice for the VertexList template parameter.

In case of listS the iterators are not invalidated by calling remove_vertex unless the iterator is pointing to the actual vertex that was removed.

Kirill V. Lyadvinsky
The problem with listS is that I cannot get connected_components to work with it.http://stackoverflow.com/questions/3183186/perform-connected-components-with-boost-adjacency-list-where-vertexlistlists
Dat Chu