Max Flow / Min Cut
Imagine a network of water pipes connecting a reservoir (source) to a city (sink). Each pipe has a maximum flow rate — its capacity. The question: how much water can flow through the network per second?
That's the max flow problem. The answer turns out to equal the minimum "cut" capacity — the cheapest set of pipes you'd need to sever to completely stop all water. This relationship is one of the most beautiful theorems in combinatorics.
What's a Flow Network?
Formally: a directed graph where each edge (u→v) has a capacity c(u,v) ≥ 0. We pick a source s and a sink t. A valid flow assigns a value f(u,v) to each edge satisfying:
- Capacity constraint: f(u,v) ≤ c(u,v) — can't exceed the pipe limit.
- Conservation: at every vertex except s and t, total flow in = total flow out — water doesn't pile up or disappear.
The value of the flow is the net amount leaving s (which always equals the net amount arriving at t).
Augmenting Paths
The Ford-Fulkerson method finds max flow by repeatedly finding an augmenting path — a route from s to t in the residual graph where every edge has leftover capacity (found via BFS or DFS). Send flow along this path (limited by the tightest pipe), then repeat.
Stop when no augmenting path exists. At that point, you've found max flow.
The Residual Graph — and the Crucial Backward Edge
For each pipe (u→v) with capacity c carrying flow f, the residual graph has:
- A forward edge (u→v) with remaining capacity c−f.
- A backward edge (v→u) with capacity f — modeling the ability to "undo" some previously sent flow.
Backward edges are the clever part. Without them, a greedy augmenting strategy could get stuck on a suboptimal routing. Backward edges let the algorithm reroute flow that was sent the wrong way.
Max-Flow Min-Cut Theorem
A cut partitions all vertices into two groups: S (containing the source) and T (containing the sink). Its capacity is the total capacity of edges crossing from S into T (reverse-direction edges don't count).
The theorem: maximum flow value = minimum cut capacity. The min cut is exactly the bottleneck constraining all flow. When Ford-Fulkerson finishes, the vertices still reachable from s in the residual graph form S — and the corresponding cut is the minimum cut.