Memra

Maximum flow (concept + Ford-Fulkerson)

◈ 5 cards

Flow networks, residual graphs, augmenting paths, the max-flow min-cut theorem, and Edmonds-Karp (BFS augmenting paths, O(VE²)).

Flow networks

A flow network is a directed graph where each edge has a nonnegative capacity , with a designated source and sink . A flow assigns a value to each edge subject to two rules:

  • Capacity constraint: — you cannot send more than an edge can carry.
  • Flow conservation: at every vertex except and , flow in equals flow out — nothing accumulates or appears.

The value is the net flow leaving the source. The maximum-flow problem asks for the flow of greatest value.

Residual networks and augmenting paths

The key device is the residual network , which records how the flow can still change. For each edge it provides two residual capacities:

  • Forward residual — unused capacity you can still push.
  • Backward residual — the ability to cancel existing flow and reroute it.

An edge appears in exactly when its residual capacity is positive. An augmenting path is any simple path in ; its residual capacity is the bottleneck . Augmenting along pushes units — raising forward edges and lowering the cancelled ones — increasing by . The backward edges are what let a greedy method undo a bad earlier routing choice.

The max-flow min-cut theorem (Theorem 24.6)

A cut partitions the vertices with , ; its capacity is the total capacity of edges crossing . The theorem states three equivalent conditions:

  1. is a maximum flow.
  2. contains no augmenting path.
  3. for some cut .

So max flow = min cut. The proof is constructive: when no augmenting path exists, take vertices reachable from in . Then every edge is saturated () and every edge carries zero flow, so the net flow across the cut equals its capacity, — proving maximality and exhibiting a minimum cut at once.

Ford-Fulkerson and Edmonds-Karp

Ford-Fulkerson is the method: start with , and while an augmenting path exists in , augment along it. With integer capacities each augmentation adds at least , so it terminates — but choosing the path carelessly costs , which is not polynomial in the input size (a -capacity graph can need augmentations).

Edmonds-Karp fixes this by always taking the shortest (fewest-edge) augmenting path via BFS. Then BFS distances from in increase monotonically, so each edge becomes a critical (bottleneck) edge at most times — yielding augmentations and a total of , polynomial regardless of capacity values. By the integrality theorem, integer capacities yield an integer maximum flow — which is why bipartite matching reduces to max flow: give every edge capacity and each vertex is matched at most once.

Worked example

On the CLRS Fig 24.1 network (6 vertices ) Edmonds-Karp finds a maximum flow of value 23.

12/1612/1212/200/130/40/140/90/70/4sv1v3v2v4tFirst BFS path s→v1→v3→t, bottleneck 12.
The exercise network (s, v1, v2, v3, v4, t = 0–5), every edge labelled flow/capacity, after Edmonds-Karp augments along its first BFS path s→v1→v3→t. The bottleneck is min(16, 12, 20) = 12, so 12 units ride that path and every other edge still carries 0. Conservation already holds at v1…v4.
4121314449712812sv1v3v2v4tDashed arcs cancel flow; next path s→v2→v4→t.
The residual network G_f of the flow above. A solid arc is leftover capacity c(u,v) − f(u,v); a dashed arc is the cancelling arc of capacity f(u,v) that lets a later path undo this routing. v1→v3 is saturated, so it disappears forwards and reappears as v3→v1 = 12. BFS still reaches t, so the flow is not yet maximum — the next shortest path is s→v2→v4→t with bottleneck 4.
12/1611/130/411/1412/127/74/40/919/20sv1v3v2v4tc(S,T) = 12 + 7 + 4 = 23 = |f|.
At the maximum flow, S = {s, v1, v2, v4} is exactly the set still reachable from s in the residual network and T = {v3, t} is the rest. Every edge leaving S is saturated — 12/12, 7/7, 4/4 — and the one edge coming back, v3→v2, carries 0. So |f| = c(S,T) = 23: max flow equals min cut, and the cut is read straight off the residual network.
NORMAL ~/memra/learn/comp-372/max-flow-edmonds-karp utf-8 LF