Boost Users :
Subject: Re: [Boost-users] BGL: Copying graphs and edge_descriptors confusion
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-06-28 13:29:51
On Mon, 27 Jun 2011, David Doria wrote:
>> Iterators are not preserved among copies of an object; they aren't in STL
>> either. You need to use iterators from the same graph that you are trying
>> to access with them. Note that this is also true for vertex and edge
>> descriptors for some graph types (listS is the most common).
> Ah I see. Phew, that has been driving me nuts all morning. I was
> looking at the output (operator<<) of the edge_descriptors and they
> looked correct, but I guess they were pointing to the correct
> vertices, only in the wrong graph?
Yes, probably. Some graph types do have descriptors that work across
separate graph objects, but you should not rely on that.
> Does the copy constructor do anything different than the copy_graph
> function that Cedric pointed out?
The copy constructor for adjacency_list just copies the raw data without
actually traversing the graph. I know the compressed_sparse_row version
takes arbitrary graphs and does a special-purpose algorithm that is
similar to copy_graph in behavior; I do not know what other graph types
do, but it should be equivalent to copy_graph.
-- Jeremiah Willcock
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