Edmonds-Karp Algorithm
Edmonds-Karp is Ford-Fulkerson with BFS used to select augmenting paths. By always choosing a shortest augmenting path (fewest edges), the algorithm achieves polynomial running time: regardless of capacity values.
Motivation
Ford-Fulkerson with arbitrary path selection can be pseudopolynomial (), which is exponential in the input size (since capacities are represented in binary). Edmonds-Karp removes this dependency by guaranteeing a polynomial bound on the number of augmentations.
Algorithm
EDMONDS-KARP(G, s, t):
initialise flow f = 0 on all edges
while BFS from s finds a path p to t in G_f:
c_f(p) = min{ c_f(u, v) | (u, v) on p }
for each edge (u, v) on p:
if (u, v) in G.E:
f(u, v) = f(u, v) + c_f(p)
else:
f(v, u) = f(v, u) - c_f(p)
return f
The only difference from Ford-Fulkerson is the use of BFS to find augmenting paths. Since all residual edges have weight 1 (we care about hop count), BFS naturally finds shortest paths.
Analysis
Let be the shortest-path distance (in edges) from to in .
Lemma 1 (Monotonicity): For every vertex , is non-decreasing as the algorithm progresses. Proof: when we augment along a shortest path, we saturate bottleneck edges (removing them from ) and add reverse edges. Any new path through a reverse edge is strictly longer, so distances never decrease.
Lemma 2 (Edge saturations): Each edge can be saturated at most times. An edge is saturated when it lies on a shortest augmenting path. After saturation, to be used again, flow must be pushed back through the reverse edge, which requires the distance from to increase. Since distances are bounded by , each edge saturates times.
Total bound: There are augmentations. Each BFS costs . Total: .
Comparison with Dinic
Dinic’s algorithm improves on Edmonds-Karp by finding multiple augmenting paths in a single BFS round using blocking flows. Running time: . Dinic is preferred in practice but Edmonds-Karp is the examinable variant. For bipartite matching networks, Edmonds-Karp (equivalently the Hopcroft-Karp analysis) yields .
Worked Example
Consider the “bad case” for arbitrary-path Ford-Fulkerson:
s ---M--> a ---1--> b ---M--> t
| | ^
+----M--->b----1--->a--------+
Where is a large integer. With DFS path selection alternating between and , each augmentation increases flow by 1 (bottleneck is the capacity-1 cross edges), requiring augmentations. Edmonds-Karp finds (length 3) and augments by 1, then finds (length 3), but because it always picks the shortest path, it still requires augmentations in the worst case for this specific graph.
However, the polynomial bound is independent of : here , , so bound holds, though the actual could be much larger. The bound is a guarantee, not a tight estimate.
Summary
| Aspect | Detail |
|---|---|
| Path selection | BFS (shortest by edge count) |
| Running time | |
| Key lemma | non-decreasing over augmentations |
| Edge saturations | per edge |
| Compared to FF | Polynomial, independent of capacity magnitudes |
Past Tripos: y2024p1q9, y2023p2q7.