c++ - Boost: how to remove all the out-edges for a vertex -
in boost graph library, remove_edge invalidate edge iterator, correct way remove out-edge of vertex, example, trying remove out-edge of vertex 0. code snippet in below not work properly.
graph g(n); graph_traits <graph>::out_edge_iterator ei, ei_end; (boost::tie(ei, ei_end) = out_edges(0, g); ei != ei_end; ++ei) { vertex targ = target(*ei, g); cout << "target vtx = " << targ << endl; if ( edge(0, targ, g).second != 0 ) remove_edge(0, targ, g); }
you call clear_out_edges
on source vertex out-edges (http://www.boost.org/doc/libs/1_58_0/libs/graph/doc/adjacency_list.html)
void clear_vertex(vertex_descriptor u, adjacency_list& g)
removes edges , vertex u. vertex still appears in vertex set of graph.
the affect on descriptor , iterator stability same of invoking remove_edge() of edges have u source or target.
void clear_out_edges(vertex_descriptor u, adjacency_list& g)
removes out-edges vertex u. vertex still appears in vertex set of graph.
the affect on descriptor , iterator stability same of invoking remove_edge() of edges have u source.
this operation not applicable undirected graphs (use clear_vertex() instead).
void clear_in_edges(vertex_descriptor u, adjacency_list& g)
i have support any mutablegraph, there clear_vertex
Comments
Post a Comment