Maximum Flow
Maximum Flow
Maximum Flows
a
100 100
50 50
s 1 0 t
50 50
100 100
b
Maximum flow
a
100 100
100 100
s 1 0 t
100 100
100 100
b
Bipartite matching via maximum flow
a b c
d e f
Direct edges from X to Y, add source s sink t, arcs
from s to all v in S, arcs from all w in Y to t, all
capacities 1 s
a b c
d e f
t
Needs an integer solution
Augmenting path method
(Ford & Fulkerson)
(v, w) is saturated if f(v, w) = c(v, w), otherwise
residual
residual capacity of (v, w):
r(v, w) = c(v, w) – f(v, w)
augmenting path: path of residual arcs from s to
t
residual capacity of an augmenting path:
minimum residual capacity of arcs on path
f ← 0;
while ∃augmenting path P do
{Δ ← residual capacity of P;
for (v, w) on P do
{f(v, w) ← f(v, w) + Δ; f(w, v) ← f(w, v) – Δ}}
Augmenting path s, a, t
a
100 100
0 0
s 1 0 t
0 0
100 100
b
Augmenting path s, b, t
a
100 100
100 100
s 1 0 t
0 0
100 100
b
No augmenting path: flow is maximum
a
100 100
100 100
s 1 0 t
100 100
100 100
b
Correctness via duality
cut: a Partition of the vertices into two parts, X
containing s and Y containing t
capacity of cut:
c(X, Y) = Σ{c(x, y)|(x, y) ∈ E & x ∈ X & y ∈ Y}
net flow across cut:
f(X, Y) = Σ{f(x, y)|(x, y) ∈ E & x ∈ X & y ∈ Y}
≤ c(X, Y)
minimum cut: a cut of minimum capacity
Lemma: If X, Y is any cut and f is any flow, f(X, Y)
= e(t).
Proof: Exercise
a
100 100
0 0
s 1 0 t
0 0
100 100
b
Augmenting path s, b, a, t
a
100 100
1 0
s 1 1 t
0 1
100 100
b
Augmenting path s, b, a, t
a
100 100
1 1
s 1 0 t
1 1
100 100
b
d ← 0; d(s) ← n; f ← 0;
for (s, v) ∈ E do f(s, v) ← c(s, v);
while ∃ active v do
if ∃ residual (v, w) ∋ d(v) > d(w) then
f(v, w) ← f(v, w) + min{e(v), r(v, w)}
[push: saturating if it saturates (v, w), non-
saturating otherwise ]
else d(v) ← 1 + min{d(w)|(v, w) residual} [label]
After initialization: flows, labels
0
a
100 100
100 0
4 s 1 0 t 0
100 0
100 100
b
0
Process a: label, push to b
1
a
100 100
100 0
4 s 1 1 t 0
100 0
100 100
b
0
Process b: label, push to t
1
a
100 100
100 0
4 s 1 1 t 0
100 100
100 100
b
1
Process b: label, push to a
1
a
100 100
100 0
4 s 1 0 t 0
100 100
100 100
b
2
Process a: push to t, no active vertices
1
a
100 100
100 100
4 s 1 0 t 0
100 100
100 100
b
2
Basic properties of algorithm
Φ = Σ{d(v)|v active}
0 ≤ Φ ≤ 2n2
A non-saturating push decreases Φ by at least
one → amortized cost ≤ 0
Amortized cost of a label of v = Δd(v)
Amortized cost of a saturating push ≤ 2n
→ #non-saturating pushes = O(n2m)
FIFO method
Define passes:
pass 0 = processing of initially active vertices
pass k + 1 = processing of vertices added to
queue during pass k
Φ = max{nd(v)|v active}
0 ≤ Φ ≤ 2n2
Φ = Σ{2e(v)d(v)/Δ|v active}
0 ≤ Φ ≤ 4n2