[Lemon-user] GraphCopy : ??
Kovács Péter
kpeter at inf.elte.hu
Tue Dec 4 19:24:55 CET 2007
Hi,
GraphCopy<> is a class for copying graphs. copyGraph() is a function
that creates an instance of GraphCopy<> and returns it, but does nothing
more, only if you call member functions of the instance.
To do the copying, you have to call the run() function of the
GraphCopy<> instance, e.g. lemon::copyGraph(LG,net.NetworkGraph).run().
With GraphCopy<> you can also copy maps easily and you can create node
and edge reference maps between the objects of the original and the new
graph.
Peter
Mitcsenkov Attila írta:
> Hi!
>
> I tried to figure out how to make a duplicate of a (List)Graph object, but now I give it up... :(
>
> In the documentation I’ve found the GraphCopy class:
> „Class to copy a graph to another graph (duplicate a graph). The simplest way of using it is through the copyGraph()<http://lemon.cs.elte.hu/pub/doc/latest/a00842.html#g44340894daf6f7d9908679cfa989dab1> function.”
>
> OK. I’ve tried both, because the documentation about it was not so verbose…
>
> Now this is the code that should work – if I understand the documentation. Possibly not, because it doesn’t work:
>
> lemon::copyGraph(LG,net.NetworkGraph); // 1
> GraphCopy<ListGraph,ListGraph> GC(LG,net.NetworkGraph); // 2
>
> for(ListGraph::NodeIt nIt(net.NetworkGraph);nIt != INVALID; ++nIt)
> cout << "X" << endl;
> for(ListGraph::NodeIt nIt(LG);nIt != INVALID; ++nIt)
> cout << "Y" << endl;
>
> I’ve tried lines number 1 and 2 both separately, but none of them was working: the output in any case was multiple X-s, and no Y-s.
>
>
> Could you please help me, how to duplicate my graph?
>
> Thanks:
> Attila
>
More information about the Lemon-user
mailing list