Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2006-04-10 16:04:27


On Mar 17, 2006, at 1:08 PM, Sean Kelly wrote:
> here is the example code that works - XFlatGraph is a listS, listS
> adjacency_list. Note if I replace the remove edge expression with
> remove_edge(*iter, _graph) the edge is intermittently not removed

>
> // Remove edges marked as simualtion only
> scheduled_for_removal.unique();
> for(std::list<XFlatView::edge_descriptor>::iterator iter =
> scheduled_for_removal.begin();
> iter != scheduled_for_removal.end();
> ++iter)
> {
> remove_edge(source(*iter, graph), target(*iter,graph), graph);
> }
>
Hmmm, this is dangerous. The problem is that once you delete the
thing that "iter" points to, "iter" is invalidated and can no longer
be used for traversal. To work around this, you should instead use
remove_edge_if.

        Doug



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