First time here? Check out the FAQ!

Ask Your Question
0

to_directed() affects original graph

asked 8 years ago

Acksl gravatar image

updated 2 years ago

tmonteil 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()
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

kcrisman gravatar image

updated 8 years ago

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.

Preview: (hide)
link

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: 8 years ago

Seen: 304 times

Last updated: Feb 23 '17