Ask Your Question
0

to_directed() affects original graph

asked 2017-02-23 11:27:23 +0100

Acksl gravatar image

updated 2023-01-10 00:01:11 +0100

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()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-02-23 12:57:39 +0100

kcrisman gravatar image

updated 2017-02-23 18:08:03 +0100

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 11:27:23 +0100

Seen: 287 times

Last updated: Feb 23 '17