Last lecture covered amortized analysis — proving sequences of operations have good average cost.
Today we start a new topic: Network Flow — a powerful framework for routing, matching, and scheduling.
We model transport networks where material moves from a source to a destination through capacity-constrained links.
A flow network is a directed graph G = (V, E) with:
A flow is a function f: V \times V \to \mathbb{R} satisfying:
Flow Value: |f| = \sum_{v} f(s,v) - \sum_{v} f(v,s), the net outflow from s.
To find a maximum flow, we need to “undo” bad flow assignments.
For flow f, residual capacity of edge (u,v) is:
G_f = (V, E_f) contains all edges with c_f(u,v) > 0.
After pushing flow f = 3 along s \to a \to t:
Forward edges (green): remaining capacity c_f = c - f Backward edges (red, dashed): capacity c_f = f to undo flow
An augmenting path p is a simple path from s to t in the residual graph G_f.
c_f(p) = \min \{ c_f(u,v) : (u,v) \in p \}
Push c_f(p) along p:
Network: all edges capacity 1. Max flow = 2.
Bad first choice: augment s \to a \to b \to t (flow = 1).
After s \to a \to b \to t (flow = 1):
Result: f(s,a) = 1, f(s,b) = 1, f(a,t) = 1, f(a,b) = 0, f(b,t) = 0. Total flow = 2 = maximum. ✓
FORD-FULKERSON(G, s, t):
for each edge (u,v): f(u,v) = 0
while there exists an augmenting path p in G_f:
cf(p) = min{cf(u,v) : (u,v) in p}
augment f along p by cf(p)
return f
Loop stops when no s \to t path exists in G_f — the residual graph has no augmenting paths.
Next lecture: Max-Flow Min-Cut Theorem proves this condition means the flow is maximum.
Question
“Why do we need backward edges in the residual graph?”
Answer: Backward edges allow us to redirect or ‘undo’ previous flow decisions that block us from the global maximum. Without them, a greedy choice can get stuck at a suboptimal flow.
CS F364: Design & Analysis of AlgorithmsTulasimohan Molli