MIT 6.1220 — Lecture 10

Maximum Flow (Part II)

Let's first analyze the runtime of our Ford-Fulkerson algorithm.

Solution. (Ford-Fulkerson) Repeatedly find augmenting paths P:=stP := s \to \dots \to t, then recompute the residual network each time. Repeat until no more augmenting paths exist. This is optimal.

Suppose all capacities are integers in [0,C][0, C], so our algorithm actually terminates.

So overall, we have a runtime of O(EVC)O(|E| \cdot |V| \cdot C), or O(EF)O(|E| \cdot F^*) where FF^* is the max flow.

Remark. This is a pseudopolynomial runtime; we can still get pseudopolynomial runtime with rational capacities! But real-numbered capacities might yield an infinite loop, so this is the best we can do.

However, if we choose our paths poorly, Ford-Fulkerson can have needlessly long runtime.

If Ford-Fulkerson picks paths suts \to u \to t and svts \to v \to t, it can finish in just two steps.
But it might also finish in 1999819998 steps if it picks paths svuts \to v \to u \to t and suvts \to u \to v \to t.

Solution. (Better Ford-Fulkerson) Repeatedly find the highest bottleneck capacity augmenting path sts \to t, and recompute the residual network each time.

How? Dijkstra's, but store the minimum encountered edge weight at each vertex. This takes O(ElogV)O(|E| \log |V|) time.

To analyze the runtime of this algorithm, we make the following claim.

Claim. For any graph GG with max flow FF^*, there exists a path sts \to t with bottleneck capacity at least FE\frac{F^*}{|E|}.

Proof: Flow Decomposition Lemma. When decomposing a flow into paths and cycles, every path / cycle created will “use up” at least one of the E|E| edges. So the flow can be decomposed into at most E|E| paths and cycles.

Now apply a probabilistic argument.   \blacksquare

Now for the runtime of Better Ford-Fulkerson.

Claim. The better Ford-Fulkerson runs in O(E2logVlog(CV))O(|E|^2 \cdot \log |V| \cdot \log (C \cdot |V|)) time.

Proof: Each step takes O(ElogV)O(|E| \cdot \log|V|) time (finding the maximum bottleneck path). Also, each step cuts the remaining flow down by a factor of 11E1 - \frac{1}{|E|}, so the total number of steps is upper-bounded by O(Elog(CV))O(|E| \cdot \log(C \cdot |V|)). The end.   \blacksquare

The gain here is that the dependence on CC is now logarithmic, not linear. This is weakly polynomial runtime.

It turns out we have other solutions.

Solution. (Edmonds-Karp) Repeatedly find the shortest (least # of edges) augmenting path sts \to t, and recompute the residual network each time. How? BFS.

This has runtime O(E2V)O(|E|^2 \cdot |V|), with no dependence on CC.

Solution. (Chen Kyng Liu … '22) You can solve this problem in O(E1+o(1)logC)O(|E|^{1 + o(1)} \cdot \log C) time.

We'll end with an application of our newfound max-flow-finding tech.

Problem. (Bipartite Matching) Given a bipartite graph LRL \sqcup R, find the largest possible matching.

Solution. (Bipartite Matching) Construct ss and tt, then direct all edges sLRts \to L \to R \to t and give them weight 11. Then the maximum flow yields the largest possible matching. (How is the “matching” constraint enforced?)   \blacksquare