Sub topic 12
Proving the O(V E^2) Bound
This chapter assumes you know BFS shortest-path distances, the residual graph, augmenting paths, and the Edmonds-Karp loop from earlier chapters. It also assumes you can follow a proof by contradiction. The goal is to show that Edmonds-Karp performs at most O(V E) augmentations. Each augmentation costs one BFS, which takes O(E) time, so the total is O(V E^2). The capacities do not appear anywhere in that bound.
Notation
Write d_f(v) for the BFS distance (number of edges) from s to v in the residual graph G_f. If v is unreachable, the distance is infinite. After an augmentation, the flow is f' and the new distances are d_f'(v).
Lemma 1: Distances Never Decrease
Claim. For every vertex v, d_f'(v) >= d_f(v).
Proof by contradiction. Suppose some distances decrease. Among the vertices whose distance decreased, pick the v with the smallest new distance d_f'(v). Let u be the vertex just before v on a shortest path in G_f'. Then d_f'(u) = d_f'(v) - 1. Because u is closer than v, the choice of v means u's distance did not decrease, so d_f(u) <= d_f'(u).
There are two cases for the edge (u, v):
(u, v)was already inG_f. Thend_f(v) <= d_f(u) + 1 <= d_f'(u) + 1 = d_f'(v). This saysv's distance did not decrease, which contradicts the assumption.(u, v)is new inG_f'. A residual edge only appears when flow is pushed along its reverse, so the augmenting path used(v, u). That path was a BFS shortest path, sod_f(u) = d_f(v) + 1. Thend_f(v) = d_f(u) - 1 <= d_f'(u) - 1 = d_f'(v) - 2. This is again a contradiction.
Lemma 2: Each Edge Is Critical Only O(V) Times
An edge on the augmenting path is critical if its residual capacity equals the bottleneck. Augmenting saturates a critical edge, so the edge leaves the residual graph. Every augmentation has at least one critical edge.
Suppose (u, v) is critical under flow f. It lies on a shortest path, so d_f(v) = d_f(u) + 1. For (u, v) to be critical again, it must first come back into the residual graph. That only happens when a later augmentation, under some flow g, pushes flow along (v, u). At that point d_g(u) = d_g(v) + 1. Lemma 1 gives d_g(v) >= d_f(v), so:
d_g(u) = d_g(v) + 1 >= d_f(v) + 1 = d_f(u) + 2Between two times that (u, v) is critical, the distance of u grows by at least 2. That distance starts at 0 or more, and while u can still reach the sink it stays at most V - 2. So (u, v) is critical at most about V / 2 times.
Putting It Together
The residual graph has at most 2E possible edges, since each original edge has a forward and a reverse direction. Each of these edges is critical O(V) times, and each augmentation has at least one critical edge. That gives O(V E) augmentations. One BFS plus one path update costs O(E), so Edmonds-Karp runs in O(V E^2).
| Quantity | Bound | Reason |
|---|---|---|
| Times an edge is critical | at most V/2 | Distance of `u` rises by at least 2 each time |
| Residual edges | at most 2E | Forward and reverse per edge |
| Augmentations | O(V E) | Every augmentation has a critical edge |
| Cost per augmentation | O(E) | BFS with adjacency lists |
Exercise
In case 2 of Lemma 1, why can we write df(u) = df(v) + 1 with equality, and not just df(u) <= df(v) + 1?
Show answer
Edmonds-Karp augments along a BFS shortest path in Gf, and (v, u) lies on that path. Every edge on a shortest path goes from one distance level to the next, so df(u) = d_f(v) + 1 exactly. A general triangle inequality would only give the weaker <=, and that would not be enough for the contradiction.
Exercise
A network has V = 100 and E = 1000. Give an upper bound on the number of augmentations Edmonds-Karp performs, using the constants from the proof.
Show answer
There are at most 2E = 2000 residual edges, and each is critical at most V/2 = 50 times. Each augmentation has at least one critical edge, so there are at most 2000 * 50 = 100,000 augmentations, whatever the capacities are.