@@ -265,11 +265,11 @@ def _all_simple_cycles_iterator_edge(self, edge, max_length=None,
265
265
sage: g = graphs.Grid2dGraph(2, 5).to_directed()
266
266
sage: it = g._all_simple_cycles_iterator_edge(((0, 0), (0, 1), None), report_weight=True)
267
267
sage: for i in range(5): print(next(it))
268
- (2, [(0, 0), (0, 1), (0, 0)])
269
- (4, [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
270
- (6, [(0, 0), (0, 1), (0, 2), (1, 2), (1, 1), (1, 0), (0, 0)])
271
- (8, [(0, 0), (0, 1), (0, 2), (0, 3), (1, 3), (1, 2), (1, 1), (1, 0), (0, 0)])
272
- (10, [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (1, 3), (1, 2), (1, 1), (1, 0), (0, 0)])
268
+ (2.0 , [(0, 0), (0, 1), (0, 0)])
269
+ (4.0 , [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
270
+ (6.0 , [(0, 0), (0, 1), (0, 2), (1, 2), (1, 1), (1, 0), (0, 0)])
271
+ (8.0 , [(0, 0), (0, 1), (0, 2), (0, 3), (1, 3), (1, 2), (1, 1), (1, 0), (0, 0)])
272
+ (10.0 , [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 4), (1, 3), (1, 2), (1, 1), (1, 0), (0, 0)])
273
273
274
274
The function works for undirected graphs as well::
275
275
@@ -841,12 +841,12 @@ def all_simple_cycles(self, starting_vertices=None, rooted=False,
841
841
sage: cycles_B = g.all_simple_cycles(weight_function=lambda e:e[0]+e[1], by_weight=True,
842
842
....: report_weight=True, algorithm='B')
843
843
sage: cycles_B
844
- [(2, [0, 1, 0]), (4, [0, 2, 0]), (6, [0, 1, 2, 0]), (6, [0, 2, 1, 0]),
845
- (6, [0, 3, 0]), (6, [1, 2, 1]), (8, [0, 1, 3, 0]), (8, [0, 3, 1, 0]),
846
- (8, [1, 3, 1]), (10, [0, 2, 3, 0]), (10, [0, 3, 2, 0]), (10, [2, 3, 2]),
847
- (12, [0, 1, 3, 2, 0]), (12, [0, 1, 2, 3, 0]), (12, [0, 2, 3, 1, 0]),
848
- (12, [0, 2, 1, 3, 0]), (12, [0, 3, 2, 1, 0]), (12, [0, 3, 1, 2, 0]),
849
- (12, [1, 2, 3, 1]), (12, [1, 3, 2, 1])]
844
+ [(2.0 , [0, 1, 0]), (4.0 , [0, 2, 0]), (6.0 , [0, 1, 2, 0]), (6.0 , [0, 2, 1, 0]),
845
+ (6.0 , [0, 3, 0]), (6.0 , [1, 2, 1]), (8.0 , [0, 1, 3, 0]), (8.0 , [0, 3, 1, 0]),
846
+ (8.0 , [1, 3, 1]), (10.0 , [0, 2, 3, 0]), (10.0 , [0, 3, 2, 0]), (10.0 , [2, 3, 2]),
847
+ (12.0 , [0, 1, 3, 2, 0]), (12.0 , [0, 1, 2, 3, 0]), (12.0 , [0, 2, 3, 1, 0]),
848
+ (12.0 , [0, 2, 1, 3, 0]), (12.0 , [0, 3, 2, 1, 0]), (12.0 , [0, 3, 1, 2, 0]),
849
+ (12.0 , [1, 2, 3, 1]), (12.0 , [1, 3, 2, 1])]
850
850
sage: cycles.sort() == cycles_B.sort()
851
851
True
852
852
0 commit comments