|
Boost Users : |
Subject: Re: [Boost-users] Remove edge
From: Michael Olea (oleaj_at_[hidden])
Date: 2009-02-16 12:23:39
On Feb 16, 2009, at 9:14 AM, Gianni Loiacono wrote:
> 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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net