MIT 6.1220 — Lecture 9

Maximum Flow (Part I)

Problem. (Max Flow) Consider a directed graph G=(V,E)G = (V, E) with a source vertex ss and a sink vertex tt. Every (directed) edge has a capacity c:ER0c: E \to \mathbb{R}^{\geq 0}, extended to all of V×VV \times V by c(u,v)=0c(u, v) = 0 when (u,v)∉E(u, v) \not \in E.

We'd like to assign a flow to every edge such that:

  1. For any eEe \in E, the flow across ee is at most the capacity of ee.

  2. There is zero net flow into or out of any vertex other than ss or tt.

Formally, let f:V×VRf: V \times V \to \mathbb{R} such that f(u,v)f(u, v) is the (signed) flow from uu to vv, with f(u,v)=f(v,u)f(u, v) = -f(v, u) and f(u,v)c(u,v)f(u, v) \leq c(u, v) for all u,vVu, v \in V (so f(u,v)=0f(u, v) = 0 if neither (u,v)(u, v) nor (v,u)(v, u) is in EE).

The net flow f|f| is defined by vVf(s,v)\sum_{v \in V} f(s, v). Find the maximum possible total flow.

Claim. Any flow assignment can be decomposed as the linear combination of paths from ss to tt and cycles.

Proof: Just induct. You never get “stuck” because of the “zero net flow” constraint, which is invariant.   \blacksquare

There's an easy upper-bound on the max flow: the minimum cut.

Definition (Min Cut). Cut the directed graph via V=STV = S \sqcup T, with sSs \in S and tTt \in T. We define:

Evidently, f(S)c(S)f(S) \leq c(S).

Claim. Consider any flow assignment ff. Given any two cuts S1T1S_1 \sqcup T_1 and S2T2S_2 \sqcup T_2, we have f(S1)=f(S2)f(S_1) = f(S_2).

(By corollary, for any cut STS \sqcup T, we have f(S)f(S) is the net flow of ff.)

Proof: Because the divergence is zero. (Formally, use the decomposition of flow into paths and cycles.)   \blacksquare

Be careful, though—the above does not say that all cuts have the same cut. It only says that all cuts have the same flow—that is, the same measure with respect to edge weights with divergence 00 everywhere.

Claim. The maximum possible flow of a graph equals the minimum possible cut.

Here's the key idea.

Definition (Residual Network). Given an assigned flow ff to a graph G=(V,E)G = (V, E), the residual network consists of Gf=(V,Ef)G_f = (V, E_f) with edge weights cf(u,v):=c(u,v)f(u,v)c_f(u, v) := c(u, v) - f(u, v), and edges Ef:={(u,v)V×Vcf(u,v)>0}E_f := \{(u, v) \in V \times V \mid c_f(u, v) > 0\}.

Importantly, some edges in GfG_f will have greater weight than the corresponding edge in GG, because flow along an edge uvu \to v increases cf(v,u)c_f(v, u).

Think of this as reflecting our ability to “undo our mistakes”.

Definition (Augmenting Path). An augmenting path is a path sts \to \dots \to t in the residual network GfG_f.

Claim. The max flow is zero if and only if there is a cut of zero.

Proof: If there's a zero cut, there's obviously zero flow. If there is zero possible flow, that means there is no path from ss to tt of positive capacity, so the cut defined by S:={vVthere is a positive-capacity path from s to v}S := \{v \in V \mid \text{there is a positive-capacity path from } s \text{ to } v\} works.   \blacksquare

It turns out that the zero case is all we need! (Like proving JNF…)

Claim. The maximum possible flow is equal to the minimum possible cut.

Proof: Consider an optimal flow assignment ff. Then GfG_f must have zero maximum possible flow, or else ff would not be optimal. This means GfG_f has a cut STS \sqcup T of zero.

Claim. For any graph GG, any cut SS, and any flow ff, we have cf(S)=c(S)f(S)c_f(S) = c(S) - f(S).

Proof: Pretty obvious. Do the algebra if you want.   \square

When there is a cut STS \sqcup T of value zero in GfG_f, we have f(S)=c(S)f(S) = c(S). Lower bound meets upper bound.   \blacksquare

More generally, the following is true.

Claim. Given any network GG and any flow ff, the following statements are equivalent.

  1. We have that ff is a max flow.

  2. We have that f=c(S)|f| = c(S) for some cut SS.

  3. We have that GfG_f has no augmenting paths.

Proof: Omitted to be DRY. (I am not writing a helper proof.)   \blacksquare

And so the most naive algorithm actually just works.

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.