| 1 | initial version |
At each loop, the graph t is reconstructed from the initial s, which is never modified. If you want to accumulate your changes, you need to modify s:
l=[1,2,3,4,5]
s=graphs.CompleteGraph(1)
for i in l:
s=s.disjoint_union(graphs.CompleteGraph(i+1))
s.order()
By the way, you can replace l with range(1,6)
| 2 | No.2 Revision |
At In your code, at each loop, the graph t is reconstructed from the initial s, which is never modified. If you want to accumulate your changes, you need to modify s:
l=[1,2,3,4,5]
s=graphs.CompleteGraph(1)
for i in l:
s=s.disjoint_union(graphs.CompleteGraph(i+1))
s.order()
By the way, you can replace l with range(1,6)
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.