creating a graph from a graph with one edge removed

14 views
Skip to first unread message

Ken Levasseur

unread,
Mar 12, 2014, 4:42:02 PM3/12/14
to sage-s...@googlegroups.com
I want to examine graphs I get by removing single edges from an initial graph and I've run into a problem.  Here it is:

For example, I start with 
c6=graphs.CycleGraph(6)
a=c6.edges()[0]
p6=c6
p6.delete_edge(a)

Now if I do this:
p6.is_tree()

I get the output I expect,  True.

However, if evaluate the following, I also get True
c6.is_tree()

Removing the edge from p6 also removes it from c6.  So p6 and c6 seem to be pointers to the same structure.  How do I create a truely new graph out of the original?

Ken Levasseur
UMass Lowell 

Christophe Bal

unread,
Mar 12, 2014, 5:01:21 PM3/12/14
to sage-s...@googlegroups.com
Hello.

This is certainly due to the way Python manages unhashable variables. If you type p6 is c6, you will obtain True, in other words, p6 and c6 are two references to the same object.

Using p6=c6.copy() will do the job.

Best regards.
Christophe BAL


--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Ken Levasseur

unread,
Mar 12, 2014, 9:56:00 PM3/12/14
to sage-s...@googlegroups.com
Christophe:

Thank you, I suspected that there must have been a method like copy, but didn't know what it was.

Ken
Reply all
Reply to author
Forward
0 new messages