Boost logo

Boost Users :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2006-12-15 08:41:55


On Thu, 2006-12-14 at 04:52 +0000, Silvia Richter wrote:
> Hi,
>
> I'm not sure whether to post here or create a new thread. But since your topic
> is very similar to my question, I'll post it here.
>
> I have been using listS for both edges and vertices with adjacency_list.
> According to the online documentation of BGL, clear_vertex() should not
> invalidate the
> adjacency_iterator in this case. However, in my code that's exactly what
> happens: I call adjacent_vertices() on a vertex A, which gives me an
> adjacency_iterator. Then I remove all edges from A by calling clear_vertex().
> Then I want to use the adjacency_iterator obtained previously to check the new
> degrees of all (previous) neighbours of the removed vertex v. But the program
> crashes with a segmentation fault, when I try to use the iterator.

Unfortunately, this won't work. Once you've called clear_vertex(), the
data that the adjacency_iterator for that vertex relies on has been
removed.

I believe the table is referring to the stability of other vertices in
the graph, e.g., clear_vertex(u) does not affect a traversal through a
different vertex v's edges.

For your case, you'll probably need to either make a copy of the
adjacent vertices before calling clear_vertex(), or use a function like
remove_out_edge_if that lets you example each edge as just before it is
removed.

  Cheers,
  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