cse 521 algorithms - university of washington · 12 a brief history of flow # year discoverer(s)...
TRANSCRIPT
![Page 1: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/1.jpg)
2
CSE 521 Algorithms
The Network Flow Problem
![Page 2: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/2.jpg)
4
How much stuff can flow from s to t?
The Network Flow Problem
5
6 7
4
3 4
1 5
3
7
6 4 s
a
b
c
x
y
z
t
![Page 3: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/3.jpg)
5 Reference: On the history of the transportation and maximum flow problems. Alexander Schrijver in Math Programming, 91: 3, 2002.
Soviet Rail Network, 1955
![Page 4: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/4.jpg)
6
Net Flow: Formal Definition
Given: A digraph G = (V,E) Two vertices s,t in V
(source & sink) A capacity c(u,v) ≥ 0
for each (u,v) ∈ E (and c(u,v) = 0 for all non-edges (u,v))
Find: A flow function f: V x V → R s.t., for all u,v:
– f(u,v) ≤ c(u,v) [Capacity Constraint] – f(u,v) = -f(v,u) [Skew Symmetry] – if u ≠ s,t, f(u,V) = 0 [Flow Conservation]
Maximizing total flow |f| = f(s,V)
∑ ∑∈ ∈= Xx Yy yxfYXf ),(),(Notation:
![Page 5: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/5.jpg)
7
f(s,u) = f(u,t) = 2 f(u,s) = f(t,u) = -2 (Why?)
f(s,t) = -f(t,s) = 0 (In every flow function for this G. Why?)
Example: A Flow Function
s u t 2/2 2/3
022 =+−=+=∑= ∈ )t,u(f)s,u(f)v,u(f)V,u(f Vv
flow/capacity, not 0.66...
![Page 6: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/6.jpg)
8
Not shown: f(u,v) if ≤ 0 Note: max flow ≥ 4 since f is a flow, |f| = 4
Example: A Flow Function
4/5
6 7
3/4
1/3 4
1 5
3/3
7
1/6 1/4 s
a
b
c
x
y
z
t
![Page 7: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/7.jpg)
9
Max Flow via a Greedy Alg?
While there is an s → t path in G
Pick such a path, p Find cp, the min capacity
of any edge in p Subtract cp from all
capacities on p Delete edges of
capacity 0
s 1 a
t
b
2
1 3
2
s 1 a
t
b
2 3
1
s 1 a
t
b
1 2
s a
t
b
2
![Page 8: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/8.jpg)
10
Max Flow via a Greedy Alg?
This does NOT always find a max flow: If you pick s →b →a →t first, Flow stuck at 2. But flow 3 possible.
s 1 a
t
b
2
1 3
2 s
1 a t
b 1 1
![Page 9: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/9.jpg)
12
A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds & Karp O(nm2) 4 1970 Dinitz O(n2m) 5 1972 Edmonds & Karp; Dinitz O(m2 log C) 6 1973 Dinitz;Gabow O(nm log C) 7 1974 Karzanov O(n3) 8 1977 Cherkassky O(n2 sqrt(m)) 9 1980 Galil & Naamad O(nm log2 n) 10 1983 Sleator & Tarjan O(nm log n) 11 1986 Goldberg &Tarjan O(nm log (n2/m)) 12 1987 Ahuja & Orlin O(nm + n2 log C) 13 1987 Ahuja et al. O(nm log(n sqrt(log C)/(m+2)) 14 1989 Cheriyan & Hagerup E(nm + n2 log2 n) 15 1990 Cheriyan et al. O(n3/log n) 16 1990 Alon O(nm + n8/3 log n) 17 1992 King et al. O(nm + n2+ε) 18 1993 Phillips & Westbrook O(nm(logm/n n + log2+ε n) 19 1994 King et al. O(nm(logm/(n log n) n) 20 1997 Goldberg & Rao O(m3/2 log(n2/m) log C) ; O(n2/3 m log(n2/m) logC) … … … …
n = # of vertices m= # of edges C = Max capacity Source: Goldberg & Rao, FOCS ‘97
![Page 10: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/10.jpg)
13
2
1
1 s
a
b
t
1
2
2
Greed Revisited
2/2
1
2/3 s
a
b
t
1
2/2
2
1
1 s
a
b
t
1
2
2
2/2
1/1
1/3 s
a
b
t
1/1
1+1/2
![Page 11: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/11.jpg)
14
Residual Capacity
The residual capacity (w.r.t. f) of (u,v) is cf(u,v) = c(u,v) - f(u,v) E.g.: cf(s,b) = 7; cf(a,x) = 1; cf(x,a) = 3; cf(x,t) = 0 (a saturated edge)
4/5
6 7
3/4
1/3 4
1 5
3/3
7
1/6 1/4 s
a
b
c
x
y
z
t
![Page 12: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/12.jpg)
15
Residual Networks & Augmenting Paths
The residual network (w.r.t. f) is the graph Gf = (V,Ef), where
Ef = { (u,v) | cf(u,v) > 0 } An augmenting path (w.r.t. f) is a simple s → t path in Gf.
![Page 13: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/13.jpg)
16
A Residual Network
4/5
6 7
3/4
1/3 4
1 5
3/3
7
1/6 1/4 s
a
b
c
x
y
z
t
4
3
1
1
1
6 7
1
2 4
1
5
3
7
5 3 s
a
b
c
x
y
z
t 1
residual network: the graph Gf = (V,Ef), where Ef = { (u,v) | cf(u,v) > 0 }
![Page 14: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/14.jpg)
17
An Augmenting Path
4/5
6 7
3/4
1/3 4
1 5
3/3
7
1/6 1/4 s
a
b
c
x
y
z
t
4
3
1
1
1
6 7
1
2 4
1
5
3
7
5 3 s
a
b
c
x
y
z
t 1
augmenting path: a simple s → t path in Gf.
![Page 15: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/15.jpg)
18
Lemma 1
If f admits an augmenting path p, then f is not maximal.
Proof: “obvious” -- augment along p by cp,
the min residual capacity of p’s edges.
![Page 16: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/16.jpg)
19
Augmenting A Flow
4/5
6 7
3/4
1/3 4
1 5
3/3
7
1/6 1/4 s
a
b
c
x
y
z
t
4
3
1
1
1
6 7
1
2 4
1
5
3
7
5 3 s
a
b
c
x
y
z
t 1
4/5
1/6 7
3/4
1/3 4
1 1/5
3/3
1/7
1/6 4 s
a
b
c
x
y
z
t
![Page 17: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/17.jpg)
20
Augmenting A Flow
5/5
6 7
3/4
2/3 4
1 5
3/3
7
2/6 2/4 s
a
b
c
x
y
z
t
3
3
2
2
2
6 7
1
1 4
1
5
3
7
4 2 s
a
b
c
x
y
z
t 2
5/5
1/6 7
3/4
2/3 4
1 1/5
3/3
1/7
1+1/6
1/4 s
a
b
c
x
y
z
t
? ?
new green, same blue;
what is result?
![Page 18: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/18.jpg)
21
Lemma 1’: Augmented Flows are Flows
If f is a flow & p an augmenting path of capacity cp, then f ’ is also a valid flow, where Proof:
a) Flow conservation – easy b) Skew symmetry – easy c) Capacity constraints – pretty easy
!"
!#
$
−
+
=
otherwise ),,(
path in ),( if ,),(
path in ),( if ,),(
),('
vufpuvcvufpvucvuf
vuf p
p
![Page 19: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/19.jpg)
22
Lma 1’: Augmented Flows are Flows
f a flow & p an aug path of cap cp, then f ’ also a valid flow. Proof (Capacity constraints):
(u,v), (v,u) not on path: no change (u,v) on path:
f ’(u,v) = f(u,v) + cp ≤ f(u,v) + cf(u,v)
= f(u,v) + c(u,v) - f(u,v) = c(u,v)
!"
!#
$
−
+
=
otherwise ),,(
path in ),( if ,),(
path in ),( if ,),(
),('
vufpuvcvufpvucvuf
vuf p
p
f ’ (v,u) = f(v,u) - cp < f(v,u) ≤ c(v,u) QED
Residual Capacity: 0 < cp ≤ cf(u,v) = c(u,v) - f(u,v) Cap Constraints: -c(v,u) ≤ f(u,v) ≤ c(u,v)
![Page 20: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/20.jpg)
23
Let (u,v) be any edge in augmenting path. Note cf(u,v) = c(u,v) – f(u,v) ≥ cp > 0
Case 1: f(u,v) ≥ 0:
Add forward flow
Lemma 1’ Example—Case 1
cp u v
v’ u’
Gf
cp cp
f(u,v)/c(u,v) u v
v’ u’
Gbefore
f(u,v)+cp/c(u,v) u v
v’ u’
Gafter
![Page 21: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/21.jpg)
24
Let (u,v) be any edge in augmenting path. Note cf(u,v) = c(u,v) – f(u,v) ≥ cp > 0
Case 2: f(u,v) ≤ -cp: f(v,u) = -f(u,v) ≥ cp
Cancel/redirect
reverse flow
Lemma 1’ Example—Case 2
cp u v
v’ u’
Gf
cp cp
f(v,u)/c(v,u) u v
v’ u’
Gbefore
f(v,u)-cp/c(v,u) u v
v’ u’
Gafter
![Page 22: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/22.jpg)
25
Let (u,v) be any edge in augmenting path. Note cf(u,v) = c(u,v) – f(u,v) ≥ cp > 0
Case 3: -cp < f(u,v) < 0: ??? [E.g., cp = 8, f(u,v) = -5]
Lemma 1’ Example—Case 3
cp u v
v’ u’
Gf
cp cp
u v v’ u’
Gbefore
u v v’ u’
Gafter
![Page 23: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/23.jpg)
26
Let (u,v) be any edge in augmenting path. Note cf(u,v) = c(u,v) – f(u,v) ≥ cp > 0
Case 3: -cp < f(u,v) < 0 cp > f(v,u) > 0:
Both: cancel/redirect reverse flow
and add forward flow
Lemma 1’ Example—Case 3
cp u v
v’ u’
Gf
cp cp
f(v,u)/c(v,u) u v
v’ u’
Gbefore
cp-f(v,u) /c(u,v)
0/c(u,v)
0/c(v,u) u v
v’ u’
Gafter
![Page 24: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/24.jpg)
27
Ford-Fulkerson Method
While Gf has an augmenting path, augment
Questions:
» Does it halt? » Does it find a maximum flow? » How fast?
![Page 25: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/25.jpg)
28
Cuts
A partition S,T of V is a cut if s ∈ S, t ∈ T. Capacity of cut S,T is ∑
∈∈
=
TvSu
vucTSc ),(),(
5
6 7
4
3 4
1 5
3
7
6 4 s
a
b
c
x
y
z
t
{s} c=18
{t} c=16 {s,b,c}
c=15
5
6
7 3
s
a
b
c
x
y
z
t
{s,x} c=21
sum of caps of edges
from S to T
![Page 26: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/26.jpg)
29
Lemma 2
For any flow f and any cut S,T, the net flow across the cut equals the total flow, i.e., |f| = f(S,T), and the net flow across the cut cannot exceed the capacity of the cut, i.e. f(S,T) ≤ c(S,T)
Corollary: Max flow ≤ Min cut
1 s
t
1 1
1 1
Cut Cap = 3 Net Flow = 1
Cut Cap = 2 Net Flow = 1
![Page 27: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/27.jpg)
30
Lemma 2
For any flow f and any cut S,T, net flow across cut = total flow ≤ cut capacity
Proof: Track a flow unit. Starts at s, ends at t. crosses cut an odd # of times; net = 1. Last crossing uses a forward edge totaled in C(S,T)
1 s
t
1 1
1 1
Cut Cap = 3 Net Flow = 1
Cut Cap = 2 Net Flow = 1
![Page 28: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/28.jpg)
31
Max Flow / Min Cut Theorem
For any flow f, the following are equivalent (1) |f| = c(S,T) for some cut S,T (a min cut)
(2) f is a maximum flow (3) f admits no augmenting path
Proof: (1) ⇒ (2): corollary to lemma 2 (2) ⇒ (3): contrapositive of lemma 1
![Page 29: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/29.jpg)
32
(3) ⇒ (1) (no aug) ⇒ (cut)
S = { u | ∃ an augmenting path wrt f from s to u } T = V - S; s ∈ S, t ∈ T For any (u,v) in S × T, ∃ an augmenting path
from s to u, but not to v. ∴ (u,v) has 0 residual capacity:
(u,v) ∈ E ⇒ saturated f(u,v) = c(u,v) (v,u) ∈ E ⇒ no flow f(u,v) = 0 = -f(v,u)
This is true for every edge crossing the cut, i.e.
s t
S T
u v
=== ∑ ∑∈ ∈Su Tv vufTSff ),(),(||),(),(),( ),(,,),(,, TScvucvuf EvuTvSuEvuTvSu ==∑∑ ∈∈∈∈∈∈
Idea
: whe
re’s
the
bottl
enec
k
![Page 30: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/30.jpg)
33
Corollaries & Facts
If Ford-Fulkerson terminates, then it’s found a max flow. It will terminate if c(e) integer or rational (but may not if they’re irrational).
However, may take exponential time, even with integer capacities:
s c a
t
b
c
c 1
c
c = 1099, say
![Page 31: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/31.jpg)
34
How to Make it Faster
Several ways. Three important ones: Edmonds-Karp ‘70; Dinitz ‘70
1st “strongly” poly time alg. (next) T = O(nm2) “Scaling” [Edmonds-Karp, ‘72; Dinitz ’72]
do largest edges first; see text, and below.
if C = max capacity, T = O(m2log C) Preflow-Push [Goldberg, Tarjan ‘86]
see text T = O(n3)
![Page 32: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/32.jpg)
35
Edmonds-Karp-Dinitz ‘70 Algorithm
Use a shortest augmenting path (via Breadth First Search in residual graph) Time: O(n m2)
![Page 33: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/33.jpg)
36
BFS/Shortest Path Lemmas
Distance from s is never reduced by: • Deleting an edge
proof: no new (hence no shorter) path created • Adding an edge (u,v), provided v is nearer
than u proof: BFS is unchanged, since v visited before (u,v) examined
s
v
u
a back edge
![Page 34: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/34.jpg)
37
Lemma 3
Let f be a flow, Gf the residual graph, and p a shortest augmenting path. Then no vertex is closer to s in the new residual graph Gf+p after augmentation along p. Proof: Augmentation only deletes edges, adds back edges
![Page 35: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/35.jpg)
38
Augmentation vs BFS
t
v
u
x
s Gf
t
v
u
x
s Gf ’ G
t
v
u
x
s
5/9
3/10 0/5
3/3
2/5
2/-
6/-
![Page 36: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/36.jpg)
39
Theorem 2
The Edmonds-Karp-Dinitiz Algorithm performs O(mn) flow augmentations
Proof:
{u,v} is critical on augmenting path p if it’s closest to s having min residual capacity. Won’t be critical again until farther from s. So each edge critical at most n times.
![Page 37: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/37.jpg)
40
Augmentation vs BFS Level
G
t
v
u
x
s Gf
t
v
u
x
s Gf ’
t
v
u
x
s
5/9
3/10 0/5
3/3
2/5
2/-
6/-
t
v
u
s
3
Glater
≥ k+1
≥ k
0 . . .
BFS
Le
vel
k -1
k
0 . . .
BFS
Le
vel
4 5
7 8
3 0
2
3
1 8
4 11
0 3
5
0
![Page 38: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/38.jpg)
41
Corollary
Edmonds-Karp-Dinitz runs in O(nm2)
![Page 39: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/39.jpg)
43
Example
![Page 40: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/40.jpg)
s
a d
b e
c f
t
10 10
10
10
10
10
10
1
9
G0: the flow problem
Illustrating the Edmonds-Karp-DinitzMax Flow Algorithm.
Figures show successive stages of the E-K-D algorithm, including the 4 augmenting paths selected, while solving a particular max-flow problem. "Real" edges in the graph are shown in black, and dashed if their residual capacity is zero. Green residual edges are the back edges created to allow "undo" of flow on a "real" edge. Each graph containing an augmenting path is drawn twice – first as a "plain" graph, then showing the layering induced by breadth-first search, together with an augmenting path chosen at that stage (light blue). G4 has no remaining augmenting paths (edges from s are saturated); G5 is the resulting max flow, with each edge annotated by "flow" / "capacity".
Note how successive augmentations push nodes steadily farther from s, and especially that (undirected) edge {a,f} is the "critical" edge twice – first in G0, when a is at depth 1 in the BFS tree, and again in G3 when f (not a) is at depth 3, which allows us to undo the "mistake" of sending any flow through this edge.
Edge capacities > 1 could be increased by any value C greater than 1 without fundamentally altering the series of graphs shown. Hence, Ford-Fulkerson (lacking the E-K-D shortest path innovation) might use ≈ C augmentations on G0, instead of 4.
![Page 41: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/41.jpg)
s
a d
b e
c f
t
10 10
10
10
10
10
10
1
9
G0: the flow problem
Illustrating the Edmonds-Karp-DinitzMax Flow Algorithm.
Figures show successive stages of the E-K-D algorithm, including the 4 augmenting paths selected, while solving a particular max-flow problem. "Real" edges in the graph are shown in black, and dashed if their residual capacity is zero. Green residual edges are the back edges created to allow "undo" of flow on a "real" edge. Each graph containing an augmenting path is drawn twice – first as a "plain" graph, then showing the layering induced by breadth-first search, together with an augmenting path chosen at that stage (light blue). G4 has no remaining augmenting paths (edges from s are saturated); G5 is the resulting max flow, with each edge annotated by "flow" / "capacity".
Note how successive augmentations push nodes steadily farther from s, and especially that (undirected) edge {a,f} is the "critical" edge twice – first in G0, when a is at depth 1 in the BFS tree, and again in G3 when f (not a) is at depth 3, which allows us to undo the "mistake" of sending any flow through this edge.
Edge capacities > 1 could be increased by any value C greater than 1 without fundamentally altering the series of graphs shown. Hence, Ford-Fulkerson (lacking the E-K-D shortest path innovation) might use ≈ C augmentations on G0, instead of 4.
t
s
a d
b e
c
f
t
10 10
10
10
10
10
9
1
10
s
a d
b e
c
f
t
9 10
10
10
10
10
8
1
10
1
0
1
s
a d
b e
c f
9 10
10
10
10
10
8
1
10
1
0 1 1
9
G0: BFS layering + Aug Path G1: BFS layering + Aug PathG1: 1st Residual Graph
![Page 42: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/42.jpg)
s
a d
b e
c f
t
10 10
10
10
10
10
10
1
9
G0: the flow problem
Illustrating the Edmonds-Karp-DinitzMax Flow Algorithm.
Figures show successive stages of the E-K-D algorithm, including the 4 augmenting paths selected, while solving a particular max-flow problem. "Real" edges in the graph are shown in black, and dashed if their residual capacity is zero. Green residual edges are the back edges created to allow "undo" of flow on a "real" edge. Each graph containing an augmenting path is drawn twice – first as a "plain" graph, then showing the layering induced by breadth-first search, together with an augmenting path chosen at that stage (light blue). G4 has no remaining augmenting paths (edges from s are saturated); G5 is the resulting max flow, with each edge annotated by "flow" / "capacity".
Note how successive augmentations push nodes steadily farther from s, and especially that (undirected) edge {a,f} is the "critical" edge twice – first in G0, when a is at depth 1 in the BFS tree, and again in G3 when f (not a) is at depth 3, which allows us to undo the "mistake" of sending any flow through this edge.
Edge capacities > 1 could be increased by any value C greater than 1 without fundamentally altering the series of graphs shown. Hence, Ford-Fulkerson (lacking the E-K-D shortest path innovation) might use ≈ C augmentations on G0, instead of 4.
t
s
a d
b e
c
f
t
10 10
10
10
10
10
9
1
10
s
a d
b e
c
f
t
9 10
10
10
10
10
8
1
10
1
0
1
s
a d
b e
c f
9 10
10
10
10
10
8
1
10
1
0 1 1
9
G0: BFS layering + Aug Path G1: BFS layering + Aug PathG1: 1st Residual Graph
![Page 43: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/43.jpg)
t
s
a d
b e
c
f
t
10 10
10
10
10
10
9
1
10
s
a d
b e
c
f
t
9 10
10
10
10
10
8
1
10
1
0
1
s
a d
b e
c f
9 10
10
10
10
10
8
1
10
1
0 1 1
9
G0: BFS layering + Aug Path G1: BFS layering + Aug PathG1: 1st Residual Graph
![Page 44: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/44.jpg)
t
s
a d
b e
c
f
t
10 10
10
10
10
10
9
1
10
s
a d
b e
c
f
t
9 10
10
10
10
10
8
1
10
1
0
1
s
a d
b e
c f
9 10
10
10
10
10
8
1
10
1
0 1 1
9
G0: BFS layering + Aug Path G1: BFS layering + Aug PathG1: 1st Residual Graph
![Page 45: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/45.jpg)
t
s
a d
b e
c
f
t
10 10
10
10
10
10
9
1
10
s
a d
b e
c
f
t
9 10
10
10
10
10
8
1
10
1
0
1
s
a d
b e
c f
9 10
10
10
10
10
8
1
10
1
0 1 1
9
G0: BFS layering + Aug Path G1: BFS layering + Aug PathG1: 1st Residual Graph
s
a d
b e
c f
t
0 10
1
1
1
10
8
1
10
10
0
19
9
9
s
a
d
b
e
c
f
t
0
10
1
1
1
10
8 1
10
10
0
1 99
9
8
s
a
d
b
e
c
f
t
0
2
1
1
1
8
0 9
8
10
0
1 99
9
8
2
2
G2: BFS layering + Aug PathG2: 2nd Residual Graph G3: 3rd Residual Graph
![Page 46: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/46.jpg)
s
a d
b e
c f
t
0 10
1
1
1
10
8
1
10
10
0
19
9
9
s
a
d
b
e
c
f
t
0
10
1
1
1
10
8 1
10
10
0
1 99
9
8
s
a
d
b
e
c
f
t
0
2
1
1
1
8
0 9
8
10
0
1 99
9
8
2
2
G2: BFS layering + Aug PathG2: 2nd Residual Graph G3: 3rd Residual Graph
![Page 47: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/47.jpg)
s
a d
b e
c f
t
0 10
1
1
1
10
8
1
10
10
0
19
9
9
s
a
d
b
e
c
f
t
0
10
1
1
1
10
8 1
10
10
0
1 99
9
8
s
a
d
b
e
c
f
t
0
2
1
1
1
8
0 9
8
10
0
1 99
9
8
2
2
G2: BFS layering + Aug PathG2: 2nd Residual Graph G3: 3rd Residual Graph
![Page 48: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/48.jpg)
s
a d
b e
c f
t
0 10
1
1
1
10
8
1
10
10
0
19
9
9
s
a
d
b
e
c
f
t
0
10
1
1
1
10
8 1
10
10
0
1 99
9
8
s
a
d
b
e
c
f
t
0
2
1
1
1
8
0 9
8
10
0
1 99
9
8
2
2
G2: BFS layering + Aug PathG2: 2nd Residual Graph G3: 3rd Residual Graph
![Page 49: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/49.jpg)
s
a d
b e
c f
t
0 10
1
1
1
10
8
1
10
10
0
19
9
9
s
a
d
b
e
c
f
t
0
10
1
1
1
10
8 1
10
10
0
1 99
9
8
s
a
d
b
e
c
f
t
0
2
1
1
1
8
0 9
8
10
0
1 99
9
8
2
2
G2: BFS layering + Aug PathG2: 2nd Residual Graph G3: 3rd Residual Graph
![Page 50: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/50.jpg)
s
a d
b e
c f
t
0 10
1
1
1
10
8
1
10
10
0
19
9
9
s
a
d
b
e
c
f
t
0
10
1
1
1
10
8 1
10
10
0
1 99
9
8
s
a
d
b
e
c
f
t
0
2
1
1
1
8
0 9
8
10
0
1 99
9
8
2
2
G2: BFS layering + Aug PathG2: 2nd Residual Graph G3: 3rd Residual Graph
s
a
d
b
e
c
f
t
0
2
1
1
1
8
9
8
10
0
1
9
9
9
8
2
2
1
s
a
d
b
e
c
f
t
1
1
0
0
9
9
9
10
0
0
10
10
10
9
1
1
0
s
a d
b e
c f
t
10/10 9/10
10/10
10/10
10/10
9/10
9/10
0/1
9/9
G3: BFS
layering +
Aug Path
G5: The Max Flow (19)
G4: 4th
Residual Graph
0
![Page 51: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/51.jpg)
s
a d
b e
c f
t
0 10
1
1
1
10
8
1
10
10
0
19
9
9
s
a
d
b
e
c
f
t
0
10
1
1
1
10
8 1
10
10
0
1 99
9
8
s
a
d
b
e
c
f
t
0
2
1
1
1
8
0 9
8
10
0
1 99
9
8
2
2
G2: BFS layering + Aug PathG2: 2nd Residual Graph G3: 3rd Residual Graph
s
a
d
b
e
c
f
t
0
2
1
1
1
8
9
8
10
0
1
9
9
9
8
2
2
1
s
a
d
b
e
c
f
t
1
1
0
0
9
9
9
10
0
0
10
10
10
9
1
1
0
s
a d
b e
c f
t
10/10 9/10
10/10
10/10
10/10
9/10
9/10
0/1
9/9
G3: BFS
layering +
Aug Path
G5: The Max Flow (19)
G4: 4th
Residual Graph
0
G4: 4th residual graph
![Page 52: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/52.jpg)
s
a
d
b
e
c
f
t
0
2
1
1
1
8
9
8
10
0
1
9
9
9
8
2
2
1
s
a
d
b
e
c
f
t
1
1
0
0
9
9
9
10
0
0
10
10
10
9
1
1
0
s
a d
b e
c f
t
10/10 9/10
10/10
10/10
10/10
9/10
9/10
0/1
9/9
G3: BFS
layering +
Aug Path
G5: The Max Flow (19)
G4: 4th
Residual Graph
0
G4: 4th residual graph
![Page 53: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/53.jpg)
s
a
d
b
e
c
f
t
0
2
1
1
1
8
9
8
10
0
1
9
9
9
8
2
2
1
s
a
d
b
e
c
f
t
1
1
0
0
9
9
9
10
0
0
10
10
10
9
1
1
0
s
a d
b e
c f
t
10/10 9/10
10/10
10/10
10/10
9/10
9/10
0/1
9/9
G3: BFS
layering +
Aug Path
G5: The Max Flow (19)
G4: 4th
Residual Graph
0
G4: 4th residual graph
![Page 54: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/54.jpg)
58
Edmonds-Karp-Dinitz ’72
A natural greedy idea – choose max capacity augmenting path first
Finding the max is slow; finding a large capacity augmenting path is quicker, and gives the O(m2 log C) algorithm “capacity scaling” algorithm below
Some slides by Kevin Wayne
![Page 55: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/55.jpg)
59
Capacity Scaling
Intuition. Choosing path with highest bottleneck capacity increases flow by max possible amount. Don't worry about finding exact highest bottleneck path. Maintain scaling parameter Δ. Let Gf (Δ) be the subgraph of the residual graph
consisting of only arcs with capacity at least Δ.
110
s
4
2
t 1
170
102
122
Gf
110
s
4
2
t
170
102
122
Gf (100)
![Page 56: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/56.jpg)
60
Capacity Scaling
Scaling-Max-Flow(G, s, t, c) { foreach e ∈ E f(e) ← 0 C ← max capacity of any edge Δ ← least power of 2 ≥ C while (Δ ≥ 1) { Gf(Δ) ← Δ-residual graph while (∃ augmenting path P in Gf(Δ)) { f ← augment(f, c, P) update Gf(Δ) } Δ ← Δ / 2 } return f }
![Page 57: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/57.jpg)
61
Capacity Scaling: Correctness
Assumption. All edge capacities are integers between 1 and C. Integrality invariant. All flow and residual capacity values are integral. Correctness. If the algorithm terminates, then f is a max flow. Pf. By integrality invariant, when Δ = 1 ⇒ Gf(Δ) = Gf. Upon termination of Δ = 1 phase, there are no augmenting paths. ▪
![Page 58: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/58.jpg)
62
Capacity Scaling: Running Time
Lemma 1. The outer while loop repeats 1 + ⎡log2 C⎤ times. Pf. Initially C ≤ Δ < 2C. Δ decreases by a factor of 2 each iteration. ▪
Lemma 2. Let f be the flow at the end of a Δ-scaling phase. Then the value of the maximum flow is at most v(f) + m Δ.
Lemma 3. There are at most 2m augmentations per scaling phase. Let f be the flow at the end of the previous scaling phase. Lemma 2 ⇒ v(f*) ≤ v(f) + m (2Δ). Each augmentation in a Δ-phase increases v(f) by at least Δ. ▪
Theorem. The scaling algorithm finds a max flow in O(m log C) augmentations. It can be implemented to run in O(m2 log C) time. ▪
proof on next slide
![Page 59: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/59.jpg)
63
Capacity Scaling: Running Time
Lemma 2. Let f be the flow at the end of a Δ-scaling phase. Then value of the maximum flow is at most v(f) + m Δ. Pf. (similar to proof of max-flow min-cut theorem) Let A be the set of nodes reachable from s in Gf(Δ); B = V-A By construction, s ∈ A, t ∈ B, so A, B is a cut We show that cap(A, B) ≤ v(f) + m Δ Key points: among edges crossing the cut
– forward edges > Δ: saturated; – backward edges > Δ: empty
€
v( f ) = f (e)e out of A∑ − f (e)
e in to A∑
≥ (c(e)e out of A∑ −Δ) − Δ
e in to A∑
= c(e)e out of A∑ − Δ
e out of A∑ − Δ
e in to A∑
≥ cap(A, B) - mΔ
original network
s
t
A B
![Page 60: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/60.jpg)
64
Section 7.4: Preflow-Push
Goldberg/Goldberg-Tarjan 1986 Most (all?) prior methods based on augmenting paths
Preflow-Push is a fundamentally different idea
Read 7.4; just a sketch here!
![Page 61: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/61.jpg)
65
Preflow-Push Sketch
Idea 1: ignore “flow conservation”; push as much flow as possible to neighbors of s, their neighbors, etc. (a “preflow”)
excess(v) = flow_in(v) – flow_out(v); always ≥ 0
Idea 2: incrementally adjust flow to shed excess Idea 3: nodes have height; push excess downhill (only)
h(s) = n; h(t) = 0; initially h(all others) = 0, but may rise if excess(v) > 0 & downhill residual edge: push flow if excess(v) > 0 & no downhill residual edge: h(v)++
Magically, this stops, quickly, & you have a max flow O(n2m); O(n3) with “highest-first” rule
![Page 62: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/62.jpg)
66
Example
a
2 b
t c
2 1
2 d s
2
2
s
a b t c d
h →
2
0
initial preflow, heights, residual graph:
graph:
![Page 63: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/63.jpg)
67
Flow Applications
![Page 64: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/64.jpg)
68
Applications of Max Flow
Many! Most look nothing like flow, at least
superficially, but are deeply connected Several interesting examples in 7.5-7.13
(7.8-7.11, 7.13 are optional, but interesting. Airline scheduling and image segmentation are especially recommended.)
A few more in following slides
![Page 65: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/65.jpg)
69
Flow Integrality Theorem
Useful facts: If all capacities are integers » Some max flow has an integer value » Ford-Fulkerson method finds a max flow in
which f(u,v) is an integer for all edges (u,v)
t s
0.5/1
0.5/1 0.5/1
0.5/1
1/1 A valid flow, but unnecessary
![Page 66: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/66.jpg)
70
7.6: Disjoint Paths
Given a digraph with designated nodes s,t, are there k edge-disjoint paths from s to t?
You might try depth-first search; you might fail… You might instead try “Is max flow ≥ k?” Success! Max-flow/min-cut also implies max number of
edge disjoint paths = min number of edges whose removal separates s from t.
Many variants: node-disjoint, undirected, … See 7.6
![Page 67: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/67.jpg)
71
7.5: Bipartite Maximum Matching
Bipartite Graphs: • G = (V,E) • V = L ∪ R (L ∩ R = ∅) • E ⊆ L × R
Matching: • A set of edges M ⊆ E
such that no two edges touch a common vertex
Problem: • Find a matching M of
maximum size
![Page 68: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/68.jpg)
72
Reducing Matching to Flow
Given bipartite G, build flow network N as follows:
• Add source s, sink t • Add edges s à L • Add edges Rà t • All edge capacities 1 Theorem:
Max flow iff max matching
s t
![Page 69: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/69.jpg)
73
Reducing Matching to Flow
Theorem: Max matching size = max flow value M → f? Easy – send flow only through M f → M? Flow Integrality Thm, + cap constraints
s t
![Page 70: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/70.jpg)
74
Notes on Matching
• Max Flow Algorithm is probably overly general here
• But most direct matching algorithms use "augmenting path”-type ideas similar to that in max flow – See text (& homework?)
• Time mn1/2 possible via Edmonds-Karp
![Page 71: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/71.jpg)
75
7.12 Baseball Elimination
Some slides by Kevin Wayne
![Page 72: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/72.jpg)
76
Baseball Elimination
Which teams have a chance of finishing the season with most wins?
» Montreal eliminated since it can finish with at most 80 wins, but Atlanta already has 83.
» wi + gi < wj ⇒ team i eliminated. » Only reason sports writers appear to be aware of. » Sufficient, but not necessary!
Team i
Against = gij Wins wi
To play gi
Losses li Atl Phi NY Mon
Montreal 77 3 82 1 2 0 - New York 78 6 78 6 0 - 0
Philly 80 3 79 1 - 0 2 Atlanta 83 8 71 - 1 6 1
![Page 73: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/73.jpg)
77
Baseball Elimination
Which teams have a chance of finishing the season with most wins?
» Philly can win 83, but still eliminated . . . » If Atlanta loses a game, then some other team wins one.
Remark. Depends on both how many games already won and left to play, and on which opponents.
Team i
Against = gij Wins wi
To play gi
Losses li Atl Phi NY Mon
Montreal 77 3 82 1 2 0 - New York 78 6 78 6 0 - 0
Philly 80 3 79 1 - 0 2 Atlanta 83 8 71 - 1 6 1
![Page 74: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/74.jpg)
78
Baseball Elimination
Baseball elimination problem. » Set of teams S. » Distinguished team s ∈ S. » Team x has won wx games already. » Teams x and y play each other gxy
additional times. » Is there any outcome of the remaining
games in which team s finishes with the most (or tied for the most) wins?
![Page 75: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/75.jpg)
79
Can team 3 finish with most wins? Assume team 3 wins all remaining games ⇒ w3 + g3 wins. Divvy remaining games so that all teams have ≤ w3 + g3 wins.
Baseball Elimination: Max Flow Formulation
s
1-5
2-5
4-5
2
4
5
t
1-2
1-4
2-4
1
g24 = 7 ∞ w3 + g3 - w4
team 4 can still win this many more games without topping team 3 games left
∞
game nodes (excluding 3)
team nodes (excluding 3)
![Page 76: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/76.jpg)
80
Baseball Elimination: As Max Flow
s
1-5
2-5
4-5
2
4
5
t
1-2
1-4
2-4
1
∞
team 4 can still win this many more games without topping team 3 games left
∞
g24 = 7 w3 + g3 - w4
game nodes (excluding 3)
team nodes (excluding 3)
Theorem. Team 3 is eliminated iff max flow ≠ games left. Integrality ⇒ each remaining x-y game added to # wins for x or y. Capacity on (x, t) edges ensure no team wins too many games. In max flow, unsaturated source edge = unplayed game; if played,
(either) winner would push ahead of team 3
![Page 77: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/77.jpg)
81
Baseball Elimination: Explanation for Sports Writers
Which teams have a chance of finishing the season with most wins?
Detroit could finish season with 49 + 27 = 76 wins.
Team i
Against =gij Wins wi
To play gi
Losses li NY Bal Bos Tor
Toronto 63 27 72 7 7 0 - Boston 69 27 66 8 2 - 0
Baltimore 71 28 63 3 - 2 7 NY 75 28 59 - 3 8 7
Detroit 49 27 86 3 4 0 0
Det
- 0 4 3
-
AL East: August 30, 1996
![Page 78: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/78.jpg)
82
Baseball Elimination: Explanation for Sports Writers
Which teams could finish the season with most wins?
Detroit could finish season with 49 + 27 = 76 wins. Certificate of elimination. R = {NY, Bal, Bos, Tor}
Have already won w(R) = 278 games. Must win at least r(R) = 27 more. Average team in R wins at least 305/4 > 76 games.
Team i
Against =gij Wins wi
To play gi
Losses li NY Bal Bos Tor
Toronto 63 27 72 7 7 0 - Boston 69 27 66 8 2 - 0
Baltimore 71 28 63 3 - 2 7 NY 75 28 59 - 3 8 7
Detroit 49 27 86 3 4 0 0
Det
- 0 4 3
- AL East: August 30, 1996
![Page 79: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/79.jpg)
83
Baseball Elimination: Explanation for Sports Writers
Certificate of elimination If then z eliminated (by subset T). Theorem. [Hoffman-Rivlin 1967] Team z is eliminated iff there exists a subset T* that eliminates z. Proof idea. Let T* = teams on source side of min cut.
€
T ⊆ S, w(T ) := wii∈T∑# wins
, g(T ) := gx y{x,y} ⊆ T
∑
# remaining games ,
€
w(T )+ g(T )| T |
LB on avg # games won
> wz + gz
![Page 80: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/80.jpg)
( 90 + 87 + 6 ) / 2 > 91, so the set T = {NY, Tor}
proves Boston is eliminated.
w l g NY Balt Tor Bos NY 90 11 - 1 6 4 Baltimore 88 6 1 - 1 4 Toronto 87 10 6 1 - 4 Boston 79 12 4 4 4 -
Note: T={NY,Tor, Balt} is NOT a certificate, since
(90+88+87+8)/3 = 91
Fig 7.21 Min cut ⇒ no flow of value g*, so Boston eliminated.
g* = 1+6+1 = 8
![Page 81: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/81.jpg)
85
Baseball Elimination: Explanation for Sports Writers
Pf of theorem. Use max flow formulation, and consider min cut (A, B). Define T* = team nodes on source side of min cut. Observe x-y ∈ A iff both x ∈ T* and y ∈ T*.
infinite capacity edges ensure if x-y ∈ A then x ∈ A and y ∈ A if x ∈ A and y ∈ A but x-y ∉ T*, then adding x-y to A decreases capacity of cut
s
y
x t x-y g24 = 7 ∞ ∞
wz + gz - wx
team x can still win this many more games
games left
![Page 82: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/82.jpg)
86
Baseball Elimination: Explanation for Sports Writers
Pf of theorem. Use max flow formulation, and consider min cut (A, B). Define T* = team nodes on source side of min cut. Observe x-y ∈ A iff both x ∈ T* and y ∈ T*. Rearranging:
g(S −{z}) > cap(A, B)
= g(S −{z})− g(T*)capacity of game edges leaving A
+ (wz + gz −wx )x∈T*∑
capacity of team edges leaving A
= g(S −{z})− g(T*) − w(T*) + |T* | (wz + gz )
€
wz + gz <w(T*)+ g(T*)
|T* |
![Page 83: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/83.jpg)
87
Matching & Baseball: Key Points
Can (sometimes) take problems that seemingly have nothing to do with flow & reduce them to a flow problem
How? Build a clever network; map allocation of stuff in original problem (match edges; wins) to allocation of flow in network. Clever edge capacities constrain solution to mimic original problem in some way. Integrality useful.
![Page 84: CSE 521 Algorithms - University of Washington · 12 A Brief History of Flow # Year Discoverer(s) Bound 1 1951 Dantzig O(n 2mC) 2 1955 Ford & Fulkerson O(nmC) 3 1970 Dinitz; Edmonds](https://reader033.vdocuments.mx/reader033/viewer/2022051814/603521740ca5bc42ba43f74a/html5/thumbnails/84.jpg)
88
Matching & Baseball: Key Points
Furthermore, in the baseball example, min cut can be translated into a succinct certificate or proof of some property that is much more transparent than “see, I ran max-flow and it says flow must be less than g*”.
These examples suggest why max flow is so important – it’s a very general tool used in many other algorithms.