> Hi all,
> I have defined my graph like this:
> typedef adjacency_list<vecS, vecS, undirectedS,NodoProperty,
> ArcoProperty> Graph2;
> And also:
> graph_traits < Graph2 >::edge_iterator ei, ei_end;
> Now, I want to delete all edges where the capacity is less than 10.
> Than I have write this code:
> for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
> {
> if (capacity2[*ei] < 10)
> {
> remove_edge(source(*ei,g),target(*ei,g),g);
> }
> }
>
> But the program after 2 cicles....it crashs :(...Why?
> Thanks a lot
remove_edge invalidates the edge iterators. You could use the
"remove_edge_if" function, or use listS for edges.
-- Michael
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
> Hi Michael,
> thanks for the answer.
> Can you write me an example for to use the remove_edge_if() function?
> I have read the docs on the site, but there isn't an example :(
> Thanks a lot
There's a little example attached below. I tried it with Boost 1.37.0
on Mac OS X 10.4.11 with g++ 4.0.1:
Graph Before remove_edge_if:
A <--> C E
B <--> B B D E C E
C <--> A B D
D <--> B C E
E <--> B D A B
Graph After remove_edge_if:
A <--> E
B <--> B B E C
C <--> B D
D <--> C
E <--> B A
-- Michael