[BGL] Can't copy_graph the simplest graph with bundled properties
The following code fails. Is it intended? If it is, how to copy a graph with bundled properties? http://coliru.stacked-crooked.com/a/b1017359126ab6f6 Thanks, AS
I am afraid you have to give a custom edge and vertex copier.
Otherwise, just copy manually. It is just two loops, one for vertices
(and relative properties) and one for edges. The only point is that
you might need to keep a temporary map between old vertex descriptors
and new one to make the edges.
On Thu, Nov 26, 2015 at 2:53 AM, Alberto Santini
The following code fails. Is it intended? If it is, how to copy a graph with bundled properties?
http://coliru.stacked-crooked.com/a/b1017359126ab6f6
Thanks, AS
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Wednesday, 2 December 2015 03:10:34 UTC+1, Paolo Bolzoni wrote:
I am afraid you have to give a custom edge and vertex copier.
My bundled properties are so trivial that I shouldn't be supposed to provide a copier (hopefully!). I figured out that if I just provide a vertex_index_map, the copy succeeds. I am not sure if the following is correct, but it gives the correct output: http://coliru.stacked-crooked.com/a/d1355b0800503892 It would be interesting to know if copy_graph(old_graph, new_graph) is any different from new_graph = old_graph. In the first case I needed the property map, in the second I don't. But is the second version correct? (I'm not even sure the first version is). I pledge that, if I manage to understand all these mechanisms right one day, I'll volunteer for the improvement of the BGL documentation (to make it more user-friendly!). :-) AS
Sorry, I am not sure. However it does seems reasonable, you are giving
the graphs the map between old descriptors and new descriptors; the
same thing you need to do for manual copying.
About operator= vs copy_graph is mainly that the Graph concept is not
required to be Assignable[1], this means that using operator= or swap
is unsafe. So they made this copy function.
I am not sure why this design choice; by intuition I'd think that
Graph should be Assignable at least in some "memberwise copy" sense.
Cheers,
Paolo
[1]http://www.boost.org/doc/libs/1_59_0/libs/graph/doc/Graph.html
On Thu, Dec 3, 2015 at 9:06 PM, Alberto Santini
On Wednesday, 2 December 2015 03:10:34 UTC+1, Paolo Bolzoni wrote:
I am afraid you have to give a custom edge and vertex copier.
My bundled properties are so trivial that I shouldn't be supposed to provide a copier (hopefully!). I figured out that if I just provide a vertex_index_map, the copy succeeds. I am not sure if the following is correct, but it gives the correct output:
http://coliru.stacked-crooked.com/a/d1355b0800503892
It would be interesting to know if copy_graph(old_graph, new_graph) is any different from new_graph = old_graph. In the first case I needed the property map, in the second I don't. But is the second version correct? (I'm not even sure the first version is).
I pledge that, if I manage to understand all these mechanisms right one day, I'll volunteer for the improvement of the BGL documentation (to make it more user-friendly!). :-)
AS
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Alberto Santini
-
Paolo Bolzoni