Part VI · Graph Algorithms Chapter 24

Maximum Flow

How much can you push from source to sink through a network of capacities — and the theorem that says the answer equals the cheapest way to cut the network in half.

A flow network is a directed graph whose edges have capacities, with a designated source and sink. The maximum-flow problem asks for the greatest rate at which material can move from source to sink without exceeding any capacity. The chapter’s centre is the max-flow min-cut theorem, one of the most useful results in combinatorial optimisation, and the Ford-Fulkerson method, whose correctness rests on the clever idea of a residual network that permits flow to be pushed backwards.

4th edition note. Renumbered from 26 to 24. Bipartite matching, previously §26.3 of this chapter, was promoted to its own Chapter 25 in the 4th edition and expanded.

Contents

  1. Flow networks
  2. The residual network
  3. Augmenting paths
  4. The Ford-Fulkerson method
  5. Cuts
  6. The max-flow min-cut theorem
  7. Edmonds-Karp
  8. Applications
  9. Recap

Flow networks

A flow network G = (V, E) is a directed graph where each edge (u,v) has a non-negative capacity c(u,v) ≥ 0. There are two distinguished vertices: the source s and the sink t. If (u,v) ∉ E then c(u,v) = 0. CLRS assumes no antiparallel edges and that every vertex lies on some path from s to t.

A flow is a function f : V × V → ℝ satisfying two properties:

PropertyStatementMeaning
Capacity constraint0 ≤ f(u,v) ≤ c(u,v) for all u,vNo edge carries more than it can hold
Flow conservationFor all u ∈ V - {s,t}: ∑ᵛ f(v,u) = ∑ᵛ f(u,v)What goes in comes out; nothing accumulates

The value of the flow is the net amount leaving the source:

|f| = ∑v∈V f(s,v) - ∑v∈V f(v,s)
Two modelling conveniences. Antiparallel edges (both (u,v) and (v,u) present) are eliminated by splitting one of them through a new intermediate vertex. Multiple sources or sinks are handled by adding a supersource with infinite-capacity edges to all real sources, and symmetrically a supersink. Both reductions cost O(V + E) and mean the theory only ever has to handle the single-source single-sink case.

The residual network

The central construction. Given a flow f, the residual network records how much more can be pushed along each edge — including the ability to undo flow already sent.

╱ c(u,v) - f(u,v) if (u,v) ∈ E // unused capacity cᵡ(u,v) = │ f(v,u) if (v,u) ∈ E // flow we could cancel ╱ 0 otherwise
The backward edges are the whole idea. If 5 units currently flow from u to v, the residual network contains an edge from v to u of capacity 5. Pushing flow along it does not move material backwards — it cancels flow that was previously routed forwards, freeing it to take a better route. Without this, a greedy algorithm can commit to a bad early routing and get stuck at a non-maximum flow.
in G, with flow u v 5 / 8 carrying 5 of capacity 8 in the residual network Gᵡ u v 3 5 the backward edge lets a later step undo this routing
Figure 24.1 — One edge and its residual counterparts: 3 units of unused capacity forwards, 5 units of cancellable flow backwards.

Augmenting paths

An augmenting path is a simple path from s to t in the residual network Gᵡ. Its residual capacity is the minimum residual capacity of any edge on it — the bottleneck. Augmenting by that amount yields a new, strictly larger flow.

Formally, if f is a flow in G and f′ is a flow in Gᵡ, then f ↑ f′ is a flow in G with value |f| + |f′| (Lemma 24.1). Pushing along an augmenting path is the special case.

The Ford-Fulkerson method

CLRS calls it a method, not an algorithm, because it does not specify how to find the augmenting path — and that choice determines the running time.

FORD-FULKERSON-METHOD(G, s, t) 1 initialize flow f to 0 2 while there exists an augmenting path p in the residual network Gᵡ 3 augment flow f along p 4 return f
With integer capacities and a bad path choice, this can be catastrophically slow. The classic example is a network with two capacity-1,000,000 edges joined by a capacity-1 edge in the middle. If each augmenting path is chosen to route through the middle edge, every augmentation increases the flow by exactly 1 and the algorithm takes 2,000,000 iterations. The running time is O(E · |f*|), which depends on the capacity values, not just the graph size — and with irrational capacities it may not terminate at all.

Cuts

A cut (S, T) of a flow network partitions V into S and T = V - S with s ∈ S and t ∈ T. The net flow across the cut is f(S,T), and the capacity of the cut is c(S,T) = ∑u∈Sv∈T c(u,v) — note that capacity counts only forward edges, while net flow subtracts the backward ones.

Two facts:

The max-flow min-cut theorem

Theorem 24.6. If f is a flow in a flow network G with source s and sink t, then the following three conditions are equivalent:
  1. f is a maximum flow in G.
  2. The residual network Gᵡ contains no augmenting paths.
  3. |f| = c(S,T) for some cut (S,T) of G.

The proof cycles 1 ⇒ 2 ⇒ 3 ⇒ 1. The interesting step is 2 ⇒ 3: if no augmenting path exists, let S be the set of vertices reachable from s in Gᵡ. Then t ∉ S, every forward edge from S to T must be saturated (or it would still be in Gᵡ), and every backward edge from T to S must carry zero flow. Hence |f| = c(S,T).

Read as a whole: the maximum flow equals the minimum cut capacity. A bottleneck in the network is not a vague notion — it is a specific set of edges whose total capacity is the throughput. This is a duality theorem, and it is the prototype for linear-programming duality in Chapter 29.

The theorem also gives correctness of Ford-Fulkerson for free: it terminates only when there are no augmenting paths, and condition 2 implies condition 1.

Edmonds-Karp

Edmonds-Karp is Ford-Fulkerson with one rule added: choose the augmenting path by breadth-first search in the residual network, so it is always a shortest augmenting path in number of edges.

That single change removes the dependence on capacity values.

Running time: O(V E²) // independent of capacities

The proof has two parts. First, the shortest-path distance δᵡ(s,v) in the residual network never decreases as augmentations proceed (Lemma 24.7). Second, each edge can become critical — be the bottleneck on the chosen path — at most |V|/2 times, because between two critical occurrences of the same edge its endpoints must move at least 2 further apart. With O(E) edges and O(V) criticalities each, there are O(VE) augmentations, and each BFS costs O(E).

AlgorithmPath choiceTime
Ford-Fulkerson (generic)AnyO(E · |f*|) — depends on capacity values
Edmonds-KarpBFS, shortest pathO(V E²)
Dinic’s algorithmBlocking flows by level graphO(V² E)
Push-relabelNo paths; local pushesO(V² E), or O(V³) with relabel-to-front
CLRS covers push-relabel methods too, which abandon augmenting paths entirely. They let vertices hold an excess of flow temporarily, violating conservation, and push it locally downhill by a height function until a valid flow emerges. Push-relabel is faster in practice on many networks and is more amenable to parallelism.

Applications

Max-flow is a reduction target — a surprising number of problems become easy once phrased as a flow.

ProblemReduction
Bipartite matchingSource to all left vertices, right vertices to sink, all capacities 1. Max flow = maximum matching. This is Chapter 25.
Edge-disjoint pathsSet every capacity to 1; max flow = the number of edge-disjoint s-t paths (Menger’s theorem).
Vertex connectivitySplit each vertex into in/out halves joined by a capacity-1 edge.
Image segmentationMin cut separates foreground from background pixels.
Project selectionMax profit becomes a min cut on a network of prerequisites.
Baseball eliminationWhether a team can still win reduces to a max-flow feasibility question.
Integrality theorem. If all capacities are integers, then Ford-Fulkerson produces a maximum flow in which every f(u,v) is an integer. This is what makes the combinatorial reductions above work — a matching cannot use half an edge, and the theorem guarantees it never has to.

Recap

The eight things to carry forward

Where this goes next

Chapter 25 takes the most important of those reductions and develops it properly: matchings in bipartite graphs, including the Hopcroft-Karp speedup, the stable-marriage problem, and the Hungarian algorithm for the weighted assignment problem.


Ch 23 — All-Pairs Shortest Paths Ch 25 — Matchings in Bipartite Graphs