Skip to content

Commit f2ef353

Browse files
committed
change to shorter code
1 parent e8362fd commit f2ef353

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/sage/graphs/path_enumeration.pyx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def yen_k_shortest_simple_paths(self, source, target, weight_function=None,
735735
[1, 6, 9, 3, 4, 5],
736736
[1, 6, 9, 11, 10, 5]]
737737
738-
When s = t and report_edge=True and report_weight=True (issue 40247)::
738+
When ``s == t`` and ``report_edge == True`` and ``report_weight == True`` (:issue:`40247`)::
739739
740740
sage: g = DiGraph([(1, 2)])
741741
sage: list(yen_k_shortest_simple_paths(g, 1, 1, report_edges=True, report_weight=True))
@@ -747,16 +747,8 @@ def yen_k_shortest_simple_paths(self, source, target, weight_function=None,
747747
raise ValueError("vertex '{}' is not in the graph".format(target))
748748

749749
if source == target:
750-
if report_weight:
751-
if report_edges:
752-
yield (0, [])
753-
else:
754-
yield (0, [source])
755-
else:
756-
if report_edges:
757-
yield []
758-
else:
759-
yield [source]
750+
P = [] if report_edges else [source]
751+
yield (0, P) if report_weight else P
760752
return
761753

762754
if self.has_loops() or self.allows_multiple_edges():

0 commit comments

Comments
 (0)