Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #16475: slightly Simplify update of edge labels (capacities)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanncohen committed Mar 15, 2015
1 parent ebc6504 commit 70ca162
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/sage/graphs/graph.py
Expand Up @@ -6585,17 +6585,16 @@ def _gomory_hu_tree(self, vertices, method="FF"):

if x in g2: # Assumes x is in g1
x,y = y,x
# If the edge x-g1_v exists, adds to its label the capacity of arc xy
if g1.has_edge(x, g1_v):
g1.set_edge_label(x, g1_v, g1.edge_label(x, g1_v) + l)
else:
# Otherwise, creates it with the good label
g1.add_edge(x, g1_v, l)
# Same thing for g2
if g2.has_edge(y, g2_v):
g2.set_edge_label(y, g2_v, g2.edge_label(y, g2_v) + l)
else:
g2.add_edge(y, g2_v, l)

# Create the new edges if necessary
if not g1.has_edge(x, g1_v):
g1.add_edge(x, g1_v, 0)
if not g2.has_edge(y, g2_v):
g2.add_edge(y, g2_v, 0)

# update the capacities
g1.set_edge_label(x, g1_v, g1.edge_label(x, g1_v) + l)
g2.set_edge_label(y, g2_v, g2.edge_label(y, g2_v) + l)

# Recursion for the two new graphs... The new "real" vertices are the intersection with
# with the previous set of "real" vertices
Expand Down

0 comments on commit 70ca162

Please sign in to comment.