Directed Graphs and Network Flows

Study Sheet

Directed Graphs and Network Flows

Digraphs and tournaments, strong connectivity, and the max-flow min-cut theorem

Directed Graphs and Tournaments

Concept
Digraphs, arcs, in-degree and out-degree

A directed graph (digraph) D=(V,A)D = (V, A) has a vertex set VV and a set AA of arcs, each an ORDERED pair (u,v)(u,v) with u≠vu \ne v, also written u→vu \to v. The out-degree d+(v)d^+(v) counts arcs leaving vv; the in-degree d−(v)d^-(v) counts arcs entering vv. Summing over all vertices,

∑v∈Vd+(v)=∑v∈Vd−(v)=∣A∣.\sum_{v \in V} d^+(v) = \sum_{v \in V} d^-(v) = |A|.

A tournament on nn vertices is a digraph whose underlying graph is KnK_n: between every pair, exactly one of u→vu \to v or v→uv \to u is present.

Topic 1's handshake lemma said every edge adds 22 to a single running total; here every arc instead adds 11 to two separate totals, one tail and one head, which is why d+d^+ and d−d^- need not agree at any one vertex even though their grand totals over the whole digraph always do. Topic 1 modeled a round robin as the undirected graph K6K_6, recording only who played whom; a tournament keeps that same complete underlying graph but orients every edge toward the loser, recording who BEAT whom. The adjacency matrix of a digraph drops the symmetry Topic 1 relied on (AuvA_{uv} need no longer equal AvuA_{vu}), but (Ak)ij(A^k)_{ij} still counts directed walks of length kk from ii to jj by the identical argument.

Example
In-degree and out-degree of a specific digraph
pqrs
DD: arcs p→q,q→r,r→p,p→r,s→pp\to q, q\to r, r\to p, p\to r, s\to p.

Let DD have vertices p,q,r,sp,q,r,s and arcs p→qp\to q, q→rq \to r, r→pr \to p, p→rp \to r, s→ps \to p — ∣A∣=5|A|=5 arcs. Reading off each vertex: d+(p)=2d^+(p)=2 (to qq and rr), d+(q)=1d^+(q)=1, d+(r)=1d^+(r)=1, d+(s)=1d^+(s)=1, summing to 5=∣A∣5=|A|; and d−(p)=2d^-(p)=2 (from rr and ss), d−(q)=1d^-(q)=1, d−(r)=2d^-(r)=2, d−(s)=0d^-(s)=0, also summing to 55. Vertex pp touches 44 arcs in all, 22 leaving and 22 entering.

Example
A genuine problem: the score sequence of a tournament
1234
The tournament on 1,2,3,41,2,3,4: scores 2,2,1,12,2,1,1.

Four teams play a round robin with results 1→21\to 2, 1→31 \to 3, 2→32 \to 3, 2→42 \to 4, 3→43 \to 4, 4→14 \to 1 (an arrow points from winner to loser). This uses every one of the (42)=6\binom{4}{2}=6 pairs exactly once, so it is a genuine tournament. The score of a team is its out-degree (wins): d+(1)=2d^+(1)=2, d+(2)=2d^+(2)=2, d+(3)=1d^+(3)=1, d+(4)=1d^+(4)=1. The score sequence (2,2,1,1)(2,2,1,1) sums to 6=(42)6=\binom{4}{2}, as it must: every game contributes exactly one win.

Example
A genuine problem: a Hamiltonian path through every team
1234
The Hamiltonian path 4→1→2→34 \to 1 \to 2 \to 3, bold.

Does the tournament above have a Hamiltonian path — a directed path visiting all 44 teams, each exactly once, always moving winner-to-loser? Try 4→1→2→34 \to 1 \to 2 \to 3: it uses the arcs 4→14\to1, 1→21\to2, 2→32\to3, all present, and visits every team exactly once. So yes — and in fact every tournament has a Hamiltonian path, however its games fall, unlike a general digraph (contrast Topic 6's search for Hamiltonian cycles in undirected graphs, which can fail outright).

Side note
Where it goes wrong

A high score tempts you to assume that team beats everyone, but tournaments need not be transitive. Three teams x,y,zx,y,z with x→yx\to y, y→zy \to z, z→xz \to x form a 33-cycle: every team has score 11, tied for the lead, yet no team beats both of the others — xx beats yy but loses to zz. A perfect round robin can still have no team that beat everybody.

Try it
Try it: a fifth team joins

In the 44-team tournament above, a fifth team 55 joins and loses to everyone: it adds the arcs 1→5,2→5,3→5,4→51\to5,2\to5,3\to5,4\to5 and nothing else. What is d+(2)d^+(2) now, and what is the new score sequence's sum?

Show the answer

Team 22's old wins over 33 and 44 still stand, and it now also beats 55, so d+(2)=2+1=3d^+(2) = 2+1 = \mathbf{3}. The new tournament has (52)=10\binom{5}{2}=10 games, so every valid score sequence on 55 teams sums to 10\mathbf{10}.

Strong Connectivity

Concept
Strong connectivity and strongly connected components

Vertices u,vu,v of a digraph DD are mutually reachable if DD has a directed u→vu\to v path AND a directed v→uv \to u path. DD is strongly connected if every pair is mutually reachable. Mutual reachability is an equivalence relation on V(D)V(D) (Topic 3 proved the undirected analogue; the proof is identical with "walk" replaced by "directed walk, both ways"), and its classes are the strongly connected components (SCCs) of DD. Collapsing each SCC to a single point gives the condensation of DD, which is always a DAG.

Strong connectivity is strictly more demanding than Topic 3's connectivity: a digraph can be weakly connected — its underlying undirected graph is one piece — while still having no way back from some vertices to others. Because mutual reachability is an equivalence relation, the SCCs still partition V(D)V(D) with no overlaps, exactly as Topic 3's components partitioned an undirected graph's vertices. The condensation being a DAG is what makes it useful: once every strongly-tangled cluster is shrunk to one node, what is left can be processed in a topological order (Topic 5), cluster by cluster, with nothing left to loop back on.

Example
Finding the SCCs of a specific digraph
abcde
D2D_2: a 33-cycle feeding a 22-cycle; the two SCCs shaded differently.

Let D2D_2 have vertices a,b,c,d,ea,b,c,d,e and arcs a→ba\to b, b→cb \to c, c→ac \to a, c→dc \to d, d→ed \to e, e→de \to d — a 33-cycle on a,b,ca,b,c feeding into a 22-cycle on d,ed,e. Inside the 33-cycle, a→b→c→aa \to b \to c \to a gives a path from aa to cc and the single arc c→ac \to a gives one back, so aa and cc are mutually reachable, and likewise every pair in {a,b,c}\{a,b,c\}; the same argument makes dd and ee mutually reachable via their 22-cycle. So D2D_2 has (at least) two strongly connected components, {a,b,c}\{a,b,c\} and {d,e}\{d,e\}.

Example
A genuine problem: is D2D_2 strongly connected?

Is there a directed path from dd back to aa in D2D_2? Every arc leaving {d,e}\{d,e\} stays inside {d,e}\{d,e\} (d→ed\to e and e→de \to d are the only arcs with tail in {d,e}\{d,e\}), so no walk starting at dd can ever reach aa, bb or cc. Hence D2D_2 is NOT strongly connected, and {a,b,c}\{a,b,c\}, {d,e}\{d,e\} really are two separate SCCs, not one — confirming the only arc joining them, c→dc \to d, runs one way.

Example
The condensation of D2D_2
1{a,b,c}{d,e}
The condensation of D2D_2: two SCCs, one arc between them.

Collapsing {a,b,c}\{a,b,c\} to a single vertex and {d,e}\{d,e\} to another leaves exactly one arc between them, {a,b,c}→{d,e}\{a,b,c\} \to \{d,e\} (coming from c→dc \to d), and no arc the other way. A digraph on 22 vertices with only one of the two possible arcs present has no directed cycle, so the condensation is a DAG, and {a,b,c},{d,e}\{a,b,c\}, \{d,e\} is already a valid topological order of it (Topic 5).

Side note
Where it goes wrong

Weakly connected does not mean strongly connected. The directed path a→b→ca \to b \to c has a connected underlying undirected graph — you can get from any vertex to any other IGNORING arrows — yet it is not strongly connected: cc cannot reach aa at all, since every arc points forward. Here every vertex is its own SCC, 33 components in all, despite the whole digraph being one piece if the arrows are erased.

Try it
Try it: SCCs of a smaller digraph

Find the strongly connected components of the digraph on x,y,z,wx,y,z,w with arcs x→yx \to y, y→xy \to x, y→zy \to z, z→wz \to w.

Show the answer

xx and yy are mutually reachable (x→yx\to y and y→xy \to x), so they share an SCC; zz has an arc out to ww but nothing comes back from ww to zz or from zz to x,yx,y, so zz and ww are each alone. The SCCs are {x,y},{z},{w}\mathbf{\{x,y\}, \{z\}, \{w\}} — 33 components in all.

Networks and Flows

Concept
Flow networks, flows and value

A flow network is a digraph DD with a nonnegative capacity c(u,v)c(u,v) on every arc, a source ss (no arcs enter it) and a sink tt (no arcs leave it). A flow ff assigns every arc a number with (i) 0≤f(u,v)≤c(u,v)0 \le f(u,v) \le c(u,v) and (ii) conservation: for every v≠s,tv \ne s,t, ∑uf(u,v)=∑wf(v,w)\sum_u f(u,v) = \sum_w f(v,w) — inflow equals outflow. The value ∣f∣|f| is the net flow out of ss, ∑wf(s,w)\sum_w f(s,w).

A capacity is a pipe width, not a requirement: a flow may use anywhere from 00 up to c(u,v)c(u,v) on each arc, so long as every intermediate vertex passes on exactly what it receives, with nothing created or destroyed partway through the network. Conservation at vv is the discrete version of "what flows in must flow out" at a junction; only ss (where flow originates) and tt (where it is absorbed) are exempt. Because conservation holds everywhere else, the total that leaves ss cannot vanish into thin air, so it must all arrive at tt — the next two sections put this single idea to work.

Example
Building a network
5323145sabct
N1N_1: capacities on each arc.

Network N1N_1 has source ss, sink tt, and vertices a,b,ca,b,c in between, with capacities c(s,a)=5c(s,a)=5, c(s,b)=3c(s,b)=3, c(a,b)=2c(a,b)=2, c(a,c)=3c(a,c)=3, c(b,c)=1c(b,c)=1, c(b,t)=4c(b,t)=4, c(c,t)=5c(c,t)=5 — 77 arcs in all. This network, and no other, is used for the rest of this topic.

Example
A genuine problem: is this assignment a valid flow, and what is its value?
5/53/32/23/31/14/44/5sabct
N1N_1 with a flow of value 88 (shown as flow/capacity).

Try f(s,a)=5f(s,a)=5, f(s,b)=3f(s,b)=3, f(a,b)=2f(a,b)=2, f(a,c)=3f(a,c)=3, f(b,c)=1f(b,c)=1, f(b,t)=4f(b,t)=4, f(c,t)=4f(c,t)=4. Every value is within its arc's capacity. Check conservation: at aa, in =5=5, out =f(a,b)+f(a,c)=2+3=5=f(a,b)+f(a,c)=2+3=5; at bb, in =f(s,b)+f(a,b)=3+2=5=f(s,b)+f(a,b)=3+2=5, out =f(b,c)+f(b,t)=1+4=5=f(b,c)+f(b,t)=1+4=5; at cc, in =f(a,c)+f(b,c)=3+1=4=f(a,c)+f(b,c)=3+1=4, out =f(c,t)=4=f(c,t)=4. All three balance, so ff is a valid flow, with value ∣f∣=f(s,a)+f(s,b)=5+3=8|f| = f(s,a)+f(s,b) = 5+3=8.

Example
A smaller, non-maximum flow is still valid

A flow need not use every arc: send f(s,a)=3f(s,a)=3, f(a,c)=3f(a,c)=3, f(c,t)=3f(c,t)=3, and f(s,b)=f(a,b)=f(b,c)=f(b,t)=0f(s,b)=f(a,b)=f(b,c)=f(b,t)=0. Conservation holds trivially at bb (0=00=0) and at aa and cc (3=33=3 each), so this is a valid flow too, with value ∣f∣=f(s,a)=3|f| = f(s,a) = 3 — smaller than the value-88 flow above. Flows are not unique, which raises the question the next two sections answer: how do you know when a flow is as large as possible?

Side note
Where it goes wrong

The value of a flow is the net amount leaving ss, NOT the sum of every arc's flow. For the value-88 flow above, adding every entry gives 5+3+2+3+1+4+4=225+3+2+3+1+4+4=22, not 88 — that sum double-counts flow that passes through aa, bb and cc on its way from ss to tt. Only the arcs actually leaving the source count toward ∣f∣|f|.

Try it
Try it: verify a flow and find its value

In N1N_1, is f(s,a)=2f(s,a)=2, f(s,b)=3f(s,b)=3, f(a,b)=0f(a,b)=0, f(a,c)=2f(a,c)=2, f(b,c)=1f(b,c)=1, f(b,t)=2f(b,t)=2, f(c,t)=3f(c,t)=3 a valid flow? If so, what is its value?

Show the answer

Capacities all hold (2≤52\le5, 3≤33\le3, 0≤20\le2, 2≤32\le3, 1≤11\le1, 2≤42\le4, 3≤53\le5). Conservation: at aa, 2=0+22=0+2; at bb, 3+0=1+23+0=1+2; at cc, 2+1=32+1=3. All balance, so it is a valid flow, with value f(s,a)+f(s,b)=2+3=5f(s,a)+f(s,b)=2+3=\mathbf{5}.

The Max-Flow Min-Cut Theorem

Concept
Cuts and the max-flow min-cut theorem

An ss-tt cut is a partition V=S⊔TV = S \sqcup T with s∈Ss \in S, t∈Tt \in T. Its capacity is

cap⁡(S,T)=∑u∈S, v∈Tc(u,v)\operatorname{cap}(S,T) = \sum_{u \in S,\, v \in T} c(u,v)

— summing ONLY arcs leaving SS, never arcs entering it. Weak duality: ∣f∣≤cap⁡(S,T)|f| \le \operatorname{cap}(S,T) for every flow ff and every cut (S,T)(S,T). The max-flow min-cut theorem (Ford-Fulkerson, 1956) sharpens this to equality: the maximum value of a flow equals the minimum capacity of an ss-tt cut.

Weak duality is nearly obvious: every unit of flow leaving ss must eventually cross from SS to TT to reach tt, since it starts in SS and ends in TT, so the flow can never exceed the total capacity available for crossing. The theorem's content is that this bound is always tight — not just an upper limit, but a target some flow actually reaches — which is exactly the capacity-weighted generalization of Menger's theorem from Topic 3 (there, every arc had capacity 11 and "flow" meant counting disjoint paths). "Why It Works" below proves both halves in full, including why the easy direction here mirrors the easy direction Topic 3 already proved.

Example
The cut S={s}S=\{s\} in N1N_1
5323145sabct
The cut S={s}S=\{s\}: capacity 5+3=85+3=8, bold.

Take S={s}S=\{s\}, T={a,b,c,t}T=\{a,b,c,t\}. The only arcs leaving SS are s→as\to a and s→bs \to b, so cap⁡(S,T)=c(s,a)+c(s,b)=5+3=8\operatorname{cap}(S,T) = c(s,a)+c(s,b) = 5+3=8. By weak duality, NO flow in N1N_1 can have value above 88 — and the flow of value 88 found in the last section meets this bound exactly, so that flow is already maximum, and ({s},{a,b,c,t})(\{s\}, \{a,b,c,t\}) is a minimum cut.

Example
A second minimum cut
5323145sabct
The cut S={s,a,b}S=\{s,a,b\}: capacity 3+1+4=83+1+4=8, bold.

Take S={s,a,b}S=\{s,a,b\}, T={c,t}T=\{c,t\} instead. Arcs s→as\to a, s→bs \to b and a→ba \to b are internal to SS and do not count; the arcs leaving SS are a→ca \to c, b→cb \to c and b→tb \to t, giving cap⁡(S,T)=3+1+4=8\operatorname{cap}(S,T) = 3+1+4=8 — the SAME capacity as the first cut. A minimum cut need not be unique: N1N_1 has (at least) two different cuts, both achieving capacity 88, matching the max flow value found earlier.

Example
A genuine problem: is S={s,b}S=\{s,b\} a minimum cut?

Take S={s,b}S=\{s,b\}, T={a,c,t}T=\{a,c,t\}. The arcs leaving SS are s→as \to a (since a∈Ta \in T), b→cb \to c and b→tb \to t, giving cap⁡(S,T)=5+1+4=10\operatorname{cap}(S,T) = 5+1+4=10. Since 10>810 > 8, this cut is valid but NOT minimum — weak duality still holds (8≤108 \le 10), it just is not tight for this particular SS.

Side note
Where it goes wrong

Cut capacity counts only arcs from SS to TT, never arcs from TT back into SS. Take S={s,a,c}S=\{s,a,c\}, T={b,t}T=\{b,t\}: the correct crossing arcs are s→bs\to b, a→ba \to b and c→tc \to t, giving cap⁡(S,T)=3+2+5=10\operatorname{cap}(S,T) = 3+2+5=10. The arc b→cb \to c runs from TT into SS and must be left out; including its capacity 11 by mistake would give the wrong total 1111.

Try it
Try it: one more cut

In N1N_1, find cap⁡(S,T)\operatorname{cap}(S,T) for S={s,a,b,c}S=\{s,a,b,c\}, T={t}T=\{t\}.

Show the answer

The only arcs leaving SS are b→tb \to t and c→tc \to t (every other arc has both ends inside SS), so cap⁡(S,T)=c(b,t)+c(c,t)=4+5=9\operatorname{cap}(S,T) = c(b,t)+c(c,t) = 4+5=\mathbf{9} — above the minimum of 88, consistent with weak duality.

Augmenting Paths

Concept
Residual graphs and the Ford-Fulkerson method

Given a flow ff, the residual graph DfD_f has, for every arc (u,v)(u,v) with f(u,v)<c(u,v)f(u,v) < c(u,v), a FORWARD residual arc u→vu \to v of capacity c(u,v)−f(u,v)c(u,v)-f(u,v); and for every arc with f(u,v)>0f(u,v) > 0, a BACKWARD residual arc v→uv \to u of capacity f(u,v)f(u,v), which undoes flow already sent. An augmenting path is any ss-tt path in DfD_f. Ford-Fulkerson: while an augmenting path exists, push flow equal to its bottleneck (minimum residual capacity) along it, then repeat.

A forward residual arc is the obvious idea — spare capacity still available on an untouched or partly-used arc — but the backward arc is the crucial second idea: it lets the algorithm reroute flow that an earlier, greedy-looking choice sent the "wrong" way, by treating already-sent flow as something that can be partially refunded and redirected. Without backward arcs, a path search can get stuck short of the maximum, as the sidenote below shows concretely. With them, "Why It Works" proves that stopping only when no augmenting path remains always means the flow found is already maximum.

Example
A network where a backward arc is essential
11111sabt
First augmenting path s→a→b→ts\to a\to b\to t, bold.

Network N2N_2 has s,a,b,ts,a,b,t with every arc capacity 11: s→as\to a, s→bs \to b, a→ba \to b, a→ta \to t, b→tb \to t. Push 11 unit along s→a→b→ts \to a \to b \to t (bottleneck min⁡(1,1,1)=1\min(1,1,1)=1): now f(s,a)=f(a,b)=f(b,t)=1f(s,a)=f(a,b)=f(b,t)=1, each saturated. The residual graph still has s→bs \to b (capacity 11, unused) and a→ta \to t (capacity 11, unused) — but also, since f(a,b)=1>0f(a,b)=1>0, a BACKWARD arc b→ab \to a of residual capacity 11. The augmenting path s→b→a→ts \to b \to a \to t uses exactly that backward arc, pushing 11 more unit.

Example
The flow after both augmenting paths
1/11/10/11/11/1sabt
N2N_2's final flow (flow/capacity): value 22, and a→ba\to b carries none.

Pushing 11 unit along s→b→a→ts \to b \to a \to t sets f(s,b)=1f(s,b)=1 and f(a,t)=1f(a,t)=1 directly, while traveling the backward arc b→ab \to a DECREASES f(a,b)f(a,b) by 11, from 11 down to 00. The final flow is f(s,a)=1f(s,a)=1, f(s,b)=1f(s,b)=1, f(a,b)=0f(a,b)=0, f(a,t)=1f(a,t)=1, f(b,t)=1f(b,t)=1 — every arc still within capacity, conservation holds at aa (1=0+11=0+1) and at bb (1+0=11+0=1) — with value ∣f∣=f(s,a)+f(s,b)=2|f|=f(s,a)+f(s,b)=2. This matches the cut {s}\{s\}, of capacity c(s,a)+c(s,b)=1+1=2c(s,a)+c(s,b)=1+1=2, so 22 is in fact the maximum.

Example
A genuine problem: finding the max flow of N1N_1
5/53/32/23/31/14/44/5sabct
N1N_1 after four augmenting paths: value 88, matching cap⁡({s})\operatorname{cap}(\{s\}).

Run Ford-Fulkerson on N1N_1 from scratch. Path s-a-c-ts\text{-}a\text{-}c\text{-}t: bottleneck min⁡(5,3,5)=3\min(5,3,5)=3, pushing f(s,a)=3,f(a,c)=3,f(c,t)=3f(s,a)=3,f(a,c)=3,f(c,t)=3. Path s-b-c-ts\text{-}b\text{-}c\text{-}t: residual c(b,c)−0=1c(b,c)-0=1 is the bottleneck, pushing f(s,b)=1,f(b,c)=1,f(c,t)=4f(s,b)=1,f(b,c)=1,f(c,t)=4. Path s-b-ts\text{-}b\text{-}t: residual c(s,b)−1=2c(s,b)-1=2 and c(b,t)=4c(b,t)=4 give bottleneck 22, pushing f(s,b)=3,f(b,t)=2f(s,b)=3,f(b,t)=2. Path s-a-b-ts\text{-}a\text{-}b\text{-}t: residual c(s,a)−3=2c(s,a)-3=2, c(a,b)=2c(a,b)=2, c(b,t)−2=2c(b,t)-2=2 give bottleneck 22, pushing f(s,a)=5,f(a,b)=2,f(b,t)=4f(s,a)=5,f(a,b)=2,f(b,t)=4. Every arc is now saturated except c→tc \to t (44 of 55), and no augmenting path remains: ss's two arcs are both saturated and nothing enters ss, so the set reachable from ss in the residual graph is just {s}\{s\}. The final value is f(s,a)+f(s,b)=5+3=8f(s,a)+f(s,b)=5+3=8, exactly the cut {s}\{s\}'s capacity found earlier.

Side note
Where it goes wrong

Searching only FORWARD arcs, never backward residual arcs, can get stuck below the true maximum. In N2N_2 above, after pushing 11 unit along s→a→b→ts\to a\to b\to t, a forward-only search from ss reaches bb (via the unused arc s→bs \to b) but then finds bb's only forward arc, b→tb \to t, already saturated — a dead end, with tt unreached. Forward-only search stops at value 11, missing the backward-arc path that reaches the true maximum of 22.

Try it
Try it: the next augmenting path

In the N1N_1 construction above, after only the first augmenting path (s-a-c-ts\text{-}a\text{-}c\text{-}t, bottleneck 33), what is the next augmenting path and its bottleneck?

Show the answer

After that one path, s→bs \to b is untouched (residual 33), b→cb \to c is untouched (residual 1=c(b,c)1=c(b,c)), and c→tc \to t has residual 5−3=25-3=2. The path s-b-c-ts\text{-}b\text{-}c\text{-}t has bottleneck min⁡(3,1,2)=1\min(3,1,2)=\mathbf{1} — matching the second step carried out above.

Why It Works

Fix a flow ff and a cut (S,T)(S,T). For every vertex v≠s,tv \ne s,t, conservation gives (∑wf(v,w))−(∑uf(u,v))=0\left(\sum_w f(v,w)\right) - \left(\sum_u f(u,v)\right) = 0; for v=sv=s this difference is exactly ∣f∣|f| by definition (no arc enters ss, so the second sum is 00). Summing this difference over every v∈Sv \in S therefore collapses to ∣f∣|f| alone, since every v∈Sv \in S other than ss contributes 00:

∣f∣=∑v∈S(∑wf(v,w)−∑uf(u,v)).|f| = \sum_{v \in S}\Big(\sum_w f(v,w) - \sum_u f(u,v)\Big).

Now expand the right side arc by arc. An arc with both ends in SS contributes +f(u,v)+f(u,v) (from uu's outflow term) and −f(u,v)-f(u,v) (from vv's inflow term), canceling exactly. An arc from TT into SS contributes only −f(u,v)-f(u,v) (from its head's inflow term, since its tail is not in SS). An arc from SS into TT contributes only +f(u,v)+f(u,v) (from its tail's outflow term). An arc with both ends in TT contributes nothing at all. So

∣f∣=∑u∈S,v∈Tf(u,v)  −  ∑u∈T,v∈Sf(u,v)  ≤  ∑u∈S,v∈Tf(u,v)  ≤  ∑u∈S,v∈Tc(u,v)=cap⁡(S,T),|f| = \sum_{u \in S, v \in T} f(u,v) \;-\; \sum_{u \in T, v \in S} f(u,v) \;\le\; \sum_{u \in S, v \in T} f(u,v) \;\le\; \sum_{u \in S, v \in T} c(u,v) = \operatorname{cap}(S,T),

using f≥0f \ge 0 for the first inequality and f≤cf \le c for the second.

Let ff be a flow with NO augmenting path in its residual graph DfD_f (Ford-Fulkerson has stopped). Let SS be the set of vertices reachable from ss in DfD_f, and T=V∖ST = V \setminus S. Since no augmenting path exists, t∉St \notin S, so (S,T)(S,T) is a genuine ss-tt cut. Take any arc u→vu \to v with u∈Su \in S, v∈Tv \in T: if f(u,v)<c(u,v)f(u,v) < c(u,v), the forward residual arc u→vu \to v would make vv reachable from ss (through uu), contradicting v∈Tv \in T; so every such arc is SATURATED, f(u,v)=c(u,v)f(u,v)=c(u,v). Take any arc u→vu \to v with u∈Tu \in T, v∈Sv \in S: if f(u,v)>0f(u,v) > 0, the backward residual arc v→uv \to u would make uu reachable from ss (through vv), contradicting u∈Tu \in T; so every such arc carries f(u,v)=0f(u,v)=0. Plugging both facts into the identity proved above,

∣f∣=∑u∈S,v∈Tf(u,v)−∑u∈T,v∈Sf(u,v)=cap⁡(S,T)−0=cap⁡(S,T).|f| = \sum_{u\in S,v\in T} f(u,v) - \sum_{u\in T,v\in S} f(u,v) = \operatorname{cap}(S,T) - 0 = \operatorname{cap}(S,T).

Now let f∗f^\ast be any MAXIMUM flow and (S∗,T∗)(S^\ast,T^\ast) any MINIMUM cut. Weak duality gives ∣f∗∣≤cap⁡(S,T)|f^\ast| \le \operatorname{cap}(S,T) (this ff is a flow, this SS a cut) and also ∣f∣≤cap⁡(S∗,T∗)|f| \le \operatorname{cap}(S^\ast,T^\ast) (this ff a flow, that cut a cut); combined with ∣f∣≤∣f∗∣|f| \le |f^\ast| (f is merely a flow) and cap⁡(S,T)≥cap⁡(S∗,T∗)\operatorname{cap}(S,T) \ge \operatorname{cap}(S^\ast,T^\ast) (that cut is minimum), the chain

cap⁡(S∗,T∗)≤cap⁡(S,T)=∣f∣≤∣f∗∣≤cap⁡(S,T)\operatorname{cap}(S^\ast,T^\ast) \le \operatorname{cap}(S,T) = |f| \le |f^\ast| \le \operatorname{cap}(S,T)

squeezes every term equal. So ∣f∣=∣f∗∣|f|=|f^\ast|: ff itself is already maximum, (S,T)(S,T) is already minimum, and both equal the common value — proving the theorem. For integer capacities this also shows Ford-Fulkerson halts: each augmentation raises the integer value ∣f∣|f| by at least 11, bounded above by the finite number cap⁡({s},V∖{s})\operatorname{cap}(\{s\}, V\setminus\{s\}), so only finitely many augmentations are possible before no path remains.

Topic 3 (Walks, Paths and Connectivity) proved only the EASY half of Menger's theorem: that the minimum size of an edge set separating ss from tt in an undirected graph GG is AT LEAST the maximum number of pairwise edge-disjoint ss-tt paths. Max-flow min-cut now supplies the missing half. Build a digraph DD from GG by replacing every undirected edge {u,v}\{u,v\} with two arcs, u→vu \to v and v→uv \to u, each of capacity 11; this is a flow network with source ss, sink tt. Every ss-tt cut (S,T)(S,T) of DD has cap⁡(S,T)\operatorname{cap}(S,T) exactly equal to the number of edges of GG crossing between SS and TT: a crossing edge {u,v}\{u,v\} with u∈S,v∈Tu\in S,v\in T contributes only its arc u→vu \to v to the cut (its reverse arc runs TT to SS and is excluded), so it contributes capacity exactly 11, and no other arcs cross. So the minimum cut capacity in DD equals the minimum edge-cut size kk separating s,ts,t in GG. By the max-flow min-cut theorem, DD has a flow of value exactly kk. Since every capacity is the integer 11, such a flow can be taken integer-valued (the augmenting paths built one at a time in the proof above only ever add or subtract whole units), so f(u,v)∈{0,1}f(u,v) \in \{0,1\} on every arc. Peel kk unit ss-tt paths off this flow one at a time: while ∣f∣>0|f|>0, some arc leaves ss with f=1f=1; walk forward along arcs carrying flow 11 (conservation guarantees each intermediate vertex you enter has some arc of flow 11 still leaving it, since inflow == outflow there) until reaching tt or revisiting a vertex. A repeated vertex marks a directed cycle entirely inside the flow; subtracting 11 from every arc of that cycle leaves a smaller valid flow of the SAME value (a cycle contributes equally to every vertex's in- and out-flow, so removing it never breaks conservation), so discard it and resume walking. Eventually the walk reaches tt, giving one directed ss-tt path along unit-flow arcs; subtract 11 from each of its arcs (now a valid flow of value exactly one less) and repeat. This terminates after extracting exactly kk directed ss-tt paths. If any two of these paths used opposite arcs of the same edge, u→vu\to v in one and v→uv \to u in another, cancel that pair first (drop both arcs from both paths, splicing the paths' remaining pieces back together where needed) — a standard fact about maximum flows is that no edge needs both directions used at once, since canceling an opposing pair of unit flows preserves every vertex's conservation and never decreases the value, so a value-kk flow using no edge in both directions always exists. With that preprocessing done, each of the kk paths uses a distinct set of underlying edges of GG, so they are kk pairwise EDGE-DISJOINT ss-tt paths in GG. This exhibits kk disjoint paths where kk is the minimum edge-cut size, so the maximum number of edge-disjoint paths is AT LEAST kk; combined with Topic 3's easy direction (at most kk), the maximum equals kk exactly — the hard direction of Menger's theorem.

Menger's VERTEX version replaces edge-disjoint paths and edge cuts with INTERNALLY vertex-disjoint paths and vertex cuts (sets of vertices, other than s,ts,t, whose removal separates them). It follows the same way, after one extra construction. Split every vertex v≠s,tv \ne s,t into two copies, vinv_{\text{in}} and voutv_{\text{out}}, joined by a single internal arc vin→voutv_{\text{in}} \to v_{\text{out}} of capacity 11 — this arc is the only way to "use" vv at all, so saturating it models visiting vv once. Every original edge {u,v}\{u,v\} becomes arcs uout→vinu_{\text{out}} \to v_{\text{in}} and vout→uinv_{\text{out}} \to u_{\text{in}}, each of capacity ∞\infty (or any number at least as large as the whole graph, since only the internal arcs are meant to bottleneck anything). A unit flow from ss to tt in this network corresponds to a path through GG that uses each intermediate vertex's internal arc at most once — exactly an internally vertex-disjoint path when many such units are combined — and a minimum cut, which (one can check) is always forced to consist entirely of internal arcs vin→voutv_{\text{in}}\to v_{\text{out}}, corresponds exactly to a minimum vertex separator. Running the same max-flow min-cut argument on this split network gives: maximum number of internally vertex-disjoint ss-tt paths equals minimum vertex-separator size — Menger's theorem for vertices.