Sub topic 4
Augmenting Paths and the Bottleneck
This chapter assumes you know how to build a residual graph from a flow (previous chapter), can run breadth-first or depth-first search, and can read Python lists and loops.
What an Augmenting Path Is
An augmenting path is a simple path from the source s to the sink t in the residual graph where every edge has residual capacity greater than zero. If such a path exists, the current flow is not maximum, because you can push more flow along it.
The path may use forward edges, which have unused capacity, and reverse edges, which carry flow that is already assigned. When the path uses a reverse edge, it cancels some existing flow and sends that flow along a different route.
The Bottleneck
The bottleneck of an augmenting path is the smallest residual capacity on it. This is the most you can push along the path without breaking a capacity constraint on any edge.
To augment along the path by its bottleneck b, do this for each edge u -> v on the path:
- Subtract
bfrom the residual capacity ofu -> v. - Add
bto the residual capacity of the reverse edgev -> u.
Conservation still holds after the update. Each internal vertex on the path gains b units coming in and b units going out. The total flow out of s grows by exactly b. At least one edge on the path, the one that set the bottleneck, drops to residual capacity zero.
Worked Example in Code
The network below has six nodes, with 0 as s and 5 as t. No flow has been sent yet, so the residual graph equals the capacity matrix.
def bottleneck(residual, path):
return min(residual[u][v] for u, v in zip(path, path[1:]))
def augment(residual, path):
b = bottleneck(residual, path)
for u, v in zip(path, path[1:]):
residual[u][v] -= b
residual[v][u] += b
return b
capacity = [
[0, 16, 13, 0, 0, 0],
[0, 0, 0, 12, 0, 0],
[0, 4, 0, 0, 14, 0],
[0, 0, 9, 0, 0, 20],
[0, 0, 0, 7, 0, 4],
[0, 0, 0, 0, 0, 0],
]
residual = [row[:] for row in capacity]
pushed = augment(residual, [0, 1, 3, 5])
print(pushed) # 12
print(residual[1][3]) # 0, the saturated bottleneck edge
print(residual[3][1]) # 12, the new reverse capacity
print(residual[0][1]) # 4, capacity left on s -> 1After this step the flow value is 12. Edge 1 -> 3 is saturated, so no later path can use it in the forward direction. Its reverse edge 3 -> 1 now lets a later path undo some of that flow if that turns out to help.
Common Errors
| Mistake | Consequence |
|---|---|
| Updating only the forward edge | Reverse capacity is never created, and the algorithm can get stuck below the maximum |
| Pushing more than the bottleneck | Some residual capacity goes negative, so the flow is no longer feasible |
| Searching the original graph instead of the residual graph | Saturated edges get reused and cancelling paths are missed |
| Computing the bottleneck after starting the updates | Edges updated earlier in the loop report the wrong capacity |
Exercise
Continuing from the residual graph above (after pushing 12 along 0 → 1 → 3 → 5), find the bottleneck of path 0 → 2 → 4 → 5 and augment along it. Then find the bottleneck of 0 → 2 → 4 → 3 → 5. What is the total flow after both augmentations?
Show answer
Path 0 → 2 → 4 → 5 has residual capacities 13, 14, 4, so its bottleneck is 4. After pushing 4, the capacities on 0 → 2 → 4 → 3 → 5 are 9, 10, 7, 8, so its bottleneck is 7. The total flow is 12 + 4 + 7 = 23.
Exercise
Why does every augmentation saturate at least one edge of the residual graph?
Show answer
The bottleneck equals the smallest residual capacity on the path. Subtracting it from every edge on the path brings that smallest edge to exactly zero.