Ask Your Question
0

to_directed() affects original graph

asked 2017-02-23 04:27:23 -0600

Acksl gravatar image

updated 2017-07-31 15:09:09 -0600

FrédéricC gravatar image

I've stumbled on what I think is a bug. When you create a directed graph from some original graph and then making changes on the new, this can affect the old one. I'm not sure if it should be like this and one should always copy the graph first. Here's a minimal example that for be gives an error "KeyError: 0".

G1=graphs.RandomGNP(5,0.5)
G1.plot(save_pos=True)
G2=G1.to_directed()
G2.delete_vertex(0)
G2.add_vertex(5)
G2.plot()
G1.plot()
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2017-02-23 05:57:39 -0600

kcrisman gravatar image

updated 2017-02-23 11:08:03 -0600

What is REALLY weird about this is that the plotting itself seems to cause the problem! The documentation gives no clue that there should be side effects, so I've opened Trac 22424.

Edit: There is already (!) a patch up, which with a little luck will be ready for merging soon.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-02-23 04:27:23 -0600

Seen: 44 times

Last updated: Feb 23