Skip to content

Commit 8f09ea2

Browse files
committed
feng, pnc have common codes
1 parent e0528b7 commit 8f09ea2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/sage/graphs/path_enumeration.pyx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def feng_k_shortest_simple_paths(self, source, target, weight_function=None,
11151115
if self.has_loops() or self.allows_multiple_edges():
11161116
G = self.to_simple(to_undirected=False, keep_label='min', immutable=False)
11171117
else:
1118-
G = self.copy()
1118+
G = self.copy(immutable=False)
11191119

11201120
G.delete_edges(G.incoming_edges(source, labels=False))
11211121
G.delete_edges(G.outgoing_edges(target, labels=False))
@@ -1175,11 +1175,6 @@ def feng_k_shortest_simple_paths(self, source, target, weight_function=None,
11751175
cdef dict idx_to_path = {0: shortest_path}
11761176
cdef int idx = 1
11771177

1178-
# candidate_paths collects (cost, path_idx, dev_idx)
1179-
# + cost is sidetrack cost from the first shortest path tree T_0
1180-
# (i.e. real length = cost + shortest_path_length in T_0)
1181-
cdef priority_queue[pair[double, pair[int, int]]] candidate_paths
1182-
11831178
# ancestor_idx_vec[v] := the first vertex of ``path[:t+1]`` or ``id_target`` reachable by
11841179
# edges of first shortest path tree from v.
11851180
cdef vector[int] ancestor_idx_vec = [-1 for _ in range(len(G) + len(unnecessary_vertices))]
@@ -1239,6 +1234,10 @@ def feng_k_shortest_simple_paths(self, source, target, weight_function=None,
12391234
return
12401235

12411236
cdef int i, deviation_i
1237+
# candidate_paths collects (cost, path_idx, dev_idx)
1238+
# + cost is sidetrack cost from the first shortest path tree T_0
1239+
# (i.e. real length = cost + shortest_path_length in T_0)
1240+
cdef priority_queue[pair[double, pair[int, int]]] candidate_paths
12421241
candidate_paths.push((0, (0, 0)))
12431242
while candidate_paths.size():
12441243
negative_cost, (path_idx, dev_idx) = candidate_paths.top()
@@ -1474,11 +1473,6 @@ def pnc_k_shortest_simple_paths(self, source, target, weight_function=None,
14741473
cdef dict idx_to_path = {0: shortest_path}
14751474
cdef int idx = 1
14761475

1477-
# candidate_paths collects (cost, path_idx, dev_idx, is_simple)
1478-
# + cost is sidetrack cost from the first shortest path tree T_0
1479-
# (i.e. real length = cost + shortest_path_length in T_0)
1480-
cdef priority_queue[pair[pair[double, bint], pair[int, int]]] candidate_paths
1481-
14821476
# ancestor_idx_vec[v] := the first vertex of ``path[:t+1]`` or ``id_target`` reachable by
14831477
# edges of first shortest path tree from v.
14841478
cdef vector[int] ancestor_idx_vec = [-1 for _ in range(len(G) + len(unnecessary_vertices))]
@@ -1538,6 +1532,10 @@ def pnc_k_shortest_simple_paths(self, source, target, weight_function=None,
15381532
return
15391533

15401534
cdef int i, deviation_i
1535+
# candidate_paths collects (cost, path_idx, dev_idx, is_simple)
1536+
# + cost is sidetrack cost from the first shortest path tree T_0
1537+
# (i.e. real length = cost + shortest_path_length in T_0)
1538+
cdef priority_queue[pair[pair[double, bint], pair[int, int]]] candidate_paths
15411539
candidate_paths.push(((0, True), (0, 0)))
15421540
while candidate_paths.size():
15431541
(negative_cost, is_simple), (path_idx, dev_idx) = candidate_paths.top()

0 commit comments

Comments
 (0)