Re: [Boost-users] [BGL] Remove all vertices from graph with zero degree
Hello Jeffrey, I'm sorry for long silence, but better later then never, Thank you very much for help! Merry Christmas! Best regards, --Dmitry
The way that I had to implement a template function to erase a graph was like: template<typename T1> inline void WorkFlow_Datum::EraseGraph(T1& g) { typedef typename std::vector
Vertices; Vertices vertices; typename boost::graph_traits<T1>::vertex_iterator vi,vi_end; for (boost::tie(vi,vi_end)=boost::vertices(g);vi!=vi_end;++vi) vertices.push_back(*vi); for (typename Vertices::reverse_iterator iter=vertices.rbegin();iter!=vertices.rend();++iter) { boost::clear_vertex(*iter,g); boost::remove_vertex(*iter,g); } } My graph uses vectors, so I suspect that you need to use something similiar to avoid iterator instability and vertice descriptor instability. The later is way a reverse iterator was needed.
participants (1)
-
Dmitry Bufistov