Skip to content

Commit fa9bb87

Browse files
Update kpathcover.py
1 parent 47b6f79 commit fa9bb87

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

flowpaths/kpathcover.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,14 @@ def __init__(
109109

110110
def __encode_path_cover(self):
111111

112+
subpath_constraint_edges = set()
113+
for subpath_constraint in self.subpath_constraints:
114+
for edge in zip(subpath_constraint[:-1], subpath_constraint[1:]):
115+
subpath_constraint_edges.add(edge)
116+
112117
# We encode that for each edge (u,v), the sum of the weights of the paths going through the edge is equal to the flow value of the edge.
113-
for u, v, data in self.G.edges(data=True):
114-
if (u, v) in self.edges_to_ignore:
118+
for u, v in self.G.edges():
119+
if (u, v) in self.edges_to_ignore or (u, v) in subpath_constraint_edges:
115120
continue
116121

117122
# We require that self.edge_vars[(u, v, i)] is 1 for at least one i

0 commit comments

Comments
 (0)