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.
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 theadjacency_list
wasvecS
, then all vertex descriptors, edge descriptors, and iterators for the graph are invalidated by this operation. <...> If you need to make frequent use of theremove_vertex()
function thelistS
selector is a much better choice for theVertexList
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.