@@ -417,16 +417,16 @@ def shortest_simple_paths(self, source, target, weight_function=None,
417
417
[1, 2, 3, 8, 9, 11, 6 ],
418
418
[1, 2, 3, 4, 5, 6 ]]
419
419
sage: list( g. shortest_simple_paths( 1, 6, report_edges=True, labels=True, by_weight=True))
420
- [[(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (6, 7 , 4) ],
421
- [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (6, 9 , 2) ],
422
- [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (6, 10 , 2) ],
423
- [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (6, 11 , 8) ],
420
+ [[(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (7, 6 , 4) ],
421
+ [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 6 , 2) ],
422
+ [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (10, 6 , 2) ],
423
+ [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (11, 6 , 8) ],
424
424
[(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 5, 2), (5, 6, 100) ]]
425
425
sage: list( g. shortest_simple_paths( 1, 6, report_edges=True, labels=True, by_weight=True, report_weight=True))
426
- [(10, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (6, 7 , 4) ]),
427
- ( 11, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (6, 9 , 2) ]) ,
428
- ( 18, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (6, 10 , 2) ]) ,
429
- ( 27, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (6, 11 , 8) ]) ,
426
+ [(10, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (7, 6 , 4) ]),
427
+ ( 11, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 6 , 2) ]) ,
428
+ ( 18, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (10, 6 , 2) ]) ,
429
+ ( 27, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (11, 6 , 8) ]) ,
430
430
( 105, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 5, 2), (5, 6, 100) ]) ]
431
431
sage: list( g. shortest_simple_paths( 1, 6, algorithm='Yen'))
432
432
[[1, 2, 3, 4, 5, 6 ],
@@ -720,16 +720,16 @@ def yen_k_shortest_simple_paths(self, source, target, weight_function=None,
720
720
[1, 2, 3, 8, 9, 11, 6 ],
721
721
[1, 2, 3, 4, 5, 6 ]]
722
722
sage: list( yen_k_shortest_simple_paths( g, 1, 6, report_edges=True, labels=True, by_weight=True))
723
- [[(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (6, 7 , 4) ],
724
- [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (6, 9 , 2) ],
725
- [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (6, 10 , 2) ],
726
- [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (6, 11 , 8) ],
723
+ [[(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (7, 6 , 4) ],
724
+ [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 6 , 2) ],
725
+ [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (10, 6 , 2) ],
726
+ [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (11, 6 , 8) ],
727
727
[(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 5, 2), (5, 6, 100) ]]
728
728
sage: list( yen_k_shortest_simple_paths( g, 1, 6, report_edges=True, labels=True, by_weight=True, report_weight=True))
729
- [(10, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (6, 7 , 4) ]),
730
- ( 11, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (6, 9 , 2) ]) ,
731
- ( 18, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (6, 10 , 2) ]) ,
732
- ( 27, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (6, 11 , 8) ]) ,
729
+ [(10, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 7, 3), (7, 6 , 4) ]),
730
+ ( 11, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 6 , 2) ]) ,
731
+ ( 18, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 10, 7), (10, 6 , 2) ]) ,
732
+ ( 27, [(1, 2, 1), (2, 3, 1), (3, 8, 5), (8, 9, 2), (9, 11, 10), (11, 6 , 8) ]) ,
733
733
( 105, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 5, 2), (5, 6, 100) ]) ]
734
734
sage: list( yen_k_shortest_simple_paths( g, 1, 6))
735
735
[[1, 2, 3, 4, 5, 6 ],
@@ -813,8 +813,8 @@ def yen_k_shortest_simple_paths(self, source, target, weight_function=None,
813
813
if report_edges and labels:
814
814
edge_labels = {(e[0 ], e[1 ]): e for e in G.edge_iterator()}
815
815
if not G.is_directed():
816
- for u, v in G.edge_iterator(labels = False ):
817
- edge_labels[v, u] = edge_labels[ u, v]
816
+ for u, v, l in G.edge_iterator(labels = True ):
817
+ edge_labels[v, u] = (v, u, l)
818
818
819
819
# heap data structure containing the candidate paths
820
820
cdef priority_queue[pair[double , pair[int , int ]]] heap_sorted_paths
0 commit comments