We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08a0a59 commit 3133514Copy full SHA for 3133514
1 file changed
ngraph/algorithms/capacity.py
@@ -395,11 +395,13 @@ def calc_graph_capacity(
395
min_ratio = float("inf")
396
for u, neighbors in succ.items():
397
for v in neighbors:
398
- assigned_flow = flow_dict[u][v]
+ # Use safe lookup: some edges may not receive any nominal flow (e.g. due to very high branching)
399
+ assigned_flow = flow_dict.get(u, {}).get(v, 0.0)
400
if assigned_flow >= MIN_FLOW:
- cap_uv = residual_cap[u].get(v, 0.0)
401
+ cap_uv = residual_cap.get(u, {}).get(v, 0.0)
402
+ # Only consider positive assignments for scaling
403
if assigned_flow > 0.0:
- ratio = cap_uv / assigned_flow
404
+ ratio = cap_uv / assigned_flow if assigned_flow != 0.0 else 0.0
405
if ratio < min_ratio:
406
min_ratio = ratio
407
0 commit comments