Sub topic 8
When Ford-Fulkerson Is Slow or Never Stops
This chapter assumes you know the Ford-Fulkerson method from the previous chapter: repeatedly find any augmenting path in the residual graph and push its bottleneck amount. It also assumes you can read Big-O notation. Ford-Fulkerson does not say which augmenting path to pick, and that choice decides how long the algorithm runs and whether it finishes at all.
Termination with Integer Capacities
If every capacity is an integer, every residual capacity stays an integer. Each augmentation pushes a bottleneck of at least 1, so the flow value goes up by at least 1 each round. The flow can never exceed the total capacity leaving the source, so the loop must stop.
Each round does one graph search (BFS or DFS) in O(E) time. If the maximum flow value is f\, there are at most f\ rounds. That gives:
| Capacities | Terminates? | Running time |
|---|---|---|
| Integers | Yes | O(E · f\*) |
| Rationals | Yes, after scaling to integers | O(E · f\*) on the scaled network |
| Irrationals | Not guaranteed | Unbounded |
The bound O(E · f\) is pseudo-polynomial: it grows with the size of the numbers*, not with the size of the graph. A capacity of 10^9 takes only about 30 bits to write down, but it can force about 10^9 rounds.
The Classic Slow Example
Take four nodes with a large capacity X on four edges and a capacity of 1 on the middle edge.
The maximum flow is 2X, and two augmentations reach it: s→a→t and s→b→t. Now suppose the path search always picks s→a→b→t, then s→b→a→t. The second path uses the reverse residual edge b→a. Each path has a bottleneck of 1, because the middle edge has capacity 1. The middle edge keeps flipping direction, and the algorithm needs 2X rounds.
def adversarial_run(X):
# Nodes: s = 0, a = 1, b = 2, t = 3; r is the residual matrix
r = [[0, X, X, 0],
[0, 0, 1, X],
[0, 0, 0, X],
[0, 0, 0, 0]]
paths = [[0, 1, 2, 3], [0, 2, 1, 3]] # s-a-b-t, then s-b-a-t
flow = steps = 0
while True:
p = paths[steps % 2]
edges = list(zip(p, p[1:]))
bottleneck = min(r[u][v] for u, v in edges)
if bottleneck == 0:
break
for u, v in edges:
r[u][v] -= bottleneck
r[v][u] += bottleneck
flow += bottleneck
steps += 1
return flow, steps
print(adversarial_run(1000)) # (2000, 2000)A DFS that explores neighbors in an unlucky order can behave this way on real inputs.
Irrational Capacities: No Guarantee of Stopping
With irrational capacities, the bottlenecks can shrink geometrically, for example by powers of r = (√5 − 1)/2. The flow then increases by smaller and smaller amounts forever. Ford and Fulkerson gave such an example, and Zwick later found small networks with only six vertices. In these networks the flow value can even converge to a number below the true maximum. Running the algorithm longer does not fix that.
What Fixes It
The fix is a rule for choosing the path. If you always augment along a shortest path, counted in number of edges, the number of rounds depends only on V and E and not on the capacities. That rule is Edmonds-Karp, covered in the next chapter.
Exercise
In the four-node example with X = 10^9, how many augmentations does the adversarial path order need, and how many does the best order need? Why does each adversarial path push only 1 unit?
Show answer
The adversarial order needs 2 × 10^9 augmentations and the best order needs 2. Each adversarial path crosses the middle edge, either forward along a→b or backward along b→a. The residual capacity of that edge is 1, so it sets the bottleneck at 1.
Exercise
Why does Ford-Fulkerson always terminate when all capacities are integers, and what bounds the number of rounds?
Show answer
The residual capacities stay integers, so every bottleneck is at least 1 and the flow value grows by at least 1 each round. The flow cannot exceed the max-flow value f, so there are at most f rounds, giving O(E · f*) total time.