G.copy() takes a long time..

31 views
Skip to first unread message

Sudarshan Iyengar

unread,
Dec 22, 2009, 4:01:48 PM12/22/09
to networkx...@googlegroups.com
>>>import networkx as nx

>>>G=nx.erdos_renyi_graph(2000,0.5)

>>>H=nx.copy()

The second line takes very less time while the third line takes a lot
of time. Why is replicating a graph taking so much time?

Dan Schult

unread,
Dec 22, 2009, 4:53:12 PM12/22/09
to networkx...@googlegroups.com
Your example has some typos in it... but it is not surprising
to me that the .copy() method is slower than creation. It is
doing a "deepcopy" of the graph data structure. You might try

>>> H=nx.Graph(G)

which copies the edges with only a shallow copy of edge data.
Perhaps we should add this to the .copy() documentation.

Dan

Sudarshan Iyengar

unread,
Dec 23, 2009, 12:31:51 AM12/23/09
to networkx...@googlegroups.com
Hi Dan,

I am sorry for the mistake in my previous email.

It wasn't H=nx.copy() it was H=G.copy()

Thank you for your input, I am still surprised why a copying action
takes so much time.

Sudarshan

> --
>
> You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
> To post to this group, send email to networkx...@googlegroups.com.
> To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.
>
>
>

Reply all
Reply to author
Forward
0 new messages