cse 202 network flow - ucsd mathematicsfan/teach/202/notes/07maxflow15.pdf · maximum flow and...
TRANSCRIPT
![Page 1: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/1.jpg)
CSE 202
Network flow
Fan Chung Graham
UC San Diego
![Page 2: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/2.jpg)
What is a network?
LAN
WANCAN MAN
HAN
![Page 3: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/3.jpg)
![Page 4: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/4.jpg)
SDSC, skitter (July 1998)
![Page 5: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/5.jpg)
An induced subgraph of the collaborationgraph with authors of Erdös number ! 2.
![Page 6: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/6.jpg)
What is a network?
graph++.A network =
![Page 7: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/7.jpg)
Network = Graph++
+ traffic demand
+ traffic capacity
+ traffic location
![Page 8: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/8.jpg)
1
Chapter 7
Network Flow
Slides by Kevin Wayne.Copyright © 2005 Pearson-Addison Wesley.All rights reserved.
![Page 9: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/9.jpg)
2
Soviet Rail Network, 1955
Reference: On the history of the transportation and maximum flow problems.Alexander Schrijver in Math Programming, 91: 3, 2002.
![Page 10: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/10.jpg)
3
Maximum Flow and Minimum Cut
Max flow and min cut.
! Two very rich algorithmic problems.
! Cornerstone problems in combinatorial optimization.
! Beautiful mathematical duality.
Nontrivial applications / reductions.
! Data mining.
! Open-pit mining.
! Project selection.
! Airline scheduling.
! Bipartite matching.
! Baseball elimination.
! Image segmentation.
! Network connectivity.
! Network reliability.
! Distributed computing.
! Egalitarian stable matching.
! Security of statistical data.
! Network intrusion detection.
! Multi-camera scene reconstruction.
! Many many more . . .
![Page 11: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/11.jpg)
4
The game of hex
![Page 12: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/12.jpg)
5
A 11 x 11 hex board
Connect the red
= cut the blue
The red player wishes to form a path
joining the two red side.
Same for the blue player.
Tip:
![Page 13: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/13.jpg)
6
A planar graph
A B
Y
X
![Page 14: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/14.jpg)
7
Maximum Flow and Minimum Cut
Max flow and min cut.
! Two very rich algorithmic problems.
! Cornerstone problems in combinatorial optimization.
! Beautiful mathematical duality.
Nontrivial applications / reductions.
! Data mining.
! Open-pit mining.
! Project selection.
! Airline scheduling.
! Bipartite matching.
! Baseball elimination.
! Image segmentation.
! Network connectivity.
! Network reliability.
! Distributed computing.
! Egalitarian stable matching.
! Security of statistical data.
! Network intrusion detection.
! Multi-camera scene reconstruction.
! Many many more . . .
![Page 15: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/15.jpg)
8
Flow network.
! Abstraction for material flowing through the edges.
! G = (V, E) = directed graph, no parallel edges.
! Two distinguished nodes: s = source, t = sink.
! c(e) = capacity of edge e.
Minimum Cut Problem
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
capacity
source sink
![Page 16: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/16.jpg)
9
Def. An s-t cut is a partition (A, B) of V with s ! A and t ! B.
Def. The capacity of a cut (A, B) is:
Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
Capacity = 10 + 5 + 15 = 30
A
cap( A, B) = c(e)e out of A
!
![Page 17: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/17.jpg)
10
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 A
Cuts
Def. An s-t cut is a partition (A, B) of V with s ! A and t ! B.
Def. The capacity of a cut (A, B) is:
cap( A, B) = c(e)e out of A
!
Capacity = 9 + 15 + 8 + 30 = 62
![Page 18: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/18.jpg)
11
Min s-t cut problem. Find an s-t cut of minimum capacity.
Minimum Cut Problem
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 A
Capacity = 10 + 8 + 10 = 28
![Page 19: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/19.jpg)
12
Def. An s-t flow is a function that satisfies:
! For each e ! E: (capacity)
! For each v ! V – {s, t}: (conservation)
Def. The value of a flow f is:
Flows
4
0
0
0
0 0
0 4 4
0
0
0
Value = 40
f (e)e in to v
! = f (e)e out of v
!
0 ! f (e) ! c(e)
capacity
flow
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 0
v( f ) = f (e) e out of s
! .
4
![Page 20: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/20.jpg)
13
Def. An s-t flow is a function that satisfies:
! For each e ! E: (capacity)
! For each v ! V – {s, t}: (conservation)
Def. The value of a flow f is:
Flows
10
6
6
11
1 10
3 8 8
0
0
0
11
capacity
flow
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 0
Value = 24
f (e)e in to v
! = f (e)e out of v
!
0 ! f (e) ! c(e)
v( f ) = f (e) e out of s
! .
4
![Page 21: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/21.jpg)
14
Max flow problem. Find s-t flow of maximum value.
Maximum Flow Problem
10
9
9
14
4 10
4 8 9
1
0 0
0
14
capacity
flow
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 0
Value = 28
![Page 22: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/22.jpg)
15
Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut.
Then, the net flow sent across the cut is equal to the amount leaving s.
Flows and Cuts
10
6
6
11
1 10
3 8 8
0
0
0
11
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 0
Value = 24
f (e)e out of A
! " f (e)e in to A
! = v( f )
4
A
![Page 23: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/23.jpg)
16
Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut.
Then, the net flow sent across the cut is equal to the amount leaving s.
Flows and Cuts
10
6
6
1 10
3 8 8
0
0
0
11
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 0
f (e)e out of A
! " f (e)e in to A
! = v( f )
Value = 6 + 0 + 8 - 1 + 11 = 24
4
11
A
![Page 24: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/24.jpg)
17
Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut.
Then, the net flow sent across the cut is equal to the amount leaving s.
Flows and Cuts
10
6
6
11
1 10
3 8 8
0
0
0
11
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 0
f (e)e out of A
! " f (e)e in to A
! = v( f )
Value = 10 - 4 + 8 - 0 + 10 = 24
4
A
![Page 25: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/25.jpg)
18
Flows and Cuts
Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then
Pf.
f (e)e out of A
! " f (e) = v( f )e in to A
! .
v( f ) = f (e)e out of s
!
=
v "A
! f (e)e out of v
! # f (e)e in to v
!$
% &
'
( )
= f (e)e out of A
! # f (e).e in to A
!
by flow conservation, all termsexcept v = s are 0
![Page 26: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/26.jpg)
19
Flows and Cuts
Weak duality. Let f be any flow, and let (A, B) be any s-t cut. Then the
value of the flow is at most the capacity of the cut.
Cut capacity = 30 ! Flow value " 30
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
Capacity = 30
A
![Page 27: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/27.jpg)
20
Weak duality. Let f be any flow. Then, for any s-t cut (A, B) we have
v(f) ! cap(A, B).
Pf.
!
Flows and Cuts
v( f ) = f (e)e out of A
! " f (e)e in to A
!
# f (e)e out of A
!
# c(e)e out of A
!
= cap(A,B)
s
t
A B
7
6
8
4
![Page 28: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/28.jpg)
21
Certificate of Optimality
Corollary. Let f be any flow, and let (A, B) be any cut.
If v(f) = cap(A, B), then f is a max flow and (A, B) is a min cut.
Value of flow = 28Cut capacity = 28 ! Flow value " 28
10
9
9
14
4 10
4 8 9
1
0 0
0
14
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4 0A
![Page 29: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/29.jpg)
22
Towards a Max Flow Algorithm
Greedy algorithm.
! Start with f(e) = 0 for all edge e ! E.
! Find an s-t path P where each edge has f(e) < c(e).
! Augment flow along path P.
! Repeat until you get stuck.
s
1
2
t
10
10
0 0
0 0
0
20
20
30
Flow value = 0
![Page 30: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/30.jpg)
23
Towards a Max Flow Algorithm
Greedy algorithm.
! Start with f(e) = 0 for all edge e ! E.
! Find an s-t path P where each edge has f(e) < c(e).
! Augment flow along path P.
! Repeat until you get stuck.
s
1
2
t
20
Flow value = 20
10
10 20
30
0 0
0 0
0
X
X
X
20
20
20
![Page 31: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/31.jpg)
24
Towards a Max Flow Algorithm
Greedy algorithm.
! Start with f(e) = 0 for all edge e ! E.
! Find an s-t path P where each edge has f(e) < c(e).
! Augment flow along path P.
! Repeat until you get stuck.
greedy = 20
s
1
2
t
20 10
10 20
30
20 0
0
20
20
opt = 30
s
1
2
t
20 10
10 20
30
20 10
10
10
20
locally optimality " global optimality
![Page 32: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/32.jpg)
25
Residual Graph
Original edge: e = (u, v) ! E.
! Flow f(e), capacity c(e).
Residual edge.
! "Undo" flow sent.
! e = (u, v) and eR = (v, u).
! Residual capacity:
Residual graph: Gf = (V, Ef ).
! Residual edges with positive residual capacity.
! Ef = {e : f(e) < c(e)} " {eR : f(e) > 0}.
u v 17
6
capacity
u v 11
residual capacity
6
residual capacity
flow
c f (e) =c(e)! f (e) if e " E
f (e) if eR " E
# $ %
![Page 33: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/33.jpg)
26
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
G:capacity
![Page 34: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/34.jpg)
7. Ford-Fulkerson Demo
![Page 35: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/35.jpg)
28
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
0
0
0
0 0 0
0
0
G:
Flow value = 0
0
flow
capacity
![Page 36: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/36.jpg)
29
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
0
0
0
0 0 0
0
0
G:
s
2
3
4
5 t 10 9
4
10 6 2
Gf:
10 8
10
8 8
8
X X
X
0
Flow value = 0
capacity
residual capacity
flow
![Page 37: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/37.jpg)
30
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
8
0
0
0 0 8
8
0 0
G:
s
2
3
4
5 t 10
4
10 6
Gf:
8
8
8
9
22
2
10
210
X
X
X2X
Flow value = 8
![Page 38: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/38.jpg)
31
0
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
10
0
0
0 2 10
8
2
G:
s
2
3
4
5 t
4
2
Gf:
10
810
2
10 7
10 6
X
66
6
X
X
8X
Flow value = 10
![Page 39: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/39.jpg)
32
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
10
0
6
6 8 10
8
2
G:
s
2
3
4
5 t1
6
Gf:
10
8 10
8
6
6
6
4
4
4
2
X
8
2
8
X
X
0X
Flow value = 16
![Page 40: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/40.jpg)
33
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
10
2
8
8 8 10
8
0
G:
s
2
3
4
5 t
6 2
Gf:
10
10
8
6
8
8
2
2 1
2
8 2
X
9
7 9
X
X
9X
X 3
Flow value = 18
![Page 41: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/41.jpg)
34
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
10
3
9
9 9 10
7
0
G:
s
2
3
4
5 t 1 9
1
1 6 2
Gf:
10
7 10
6
9
9
3
1
Flow value = 19
![Page 42: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/42.jpg)
35
Ford-Fulkerson Algorithm
s
2
3
4
5 t 10
10
9
8
4
10
10 6 2
10
3
9
9 9 10
7
0
G:
s
2
3
4
5 t 1 9
1
1 6 2
Gf:
10
7 10
6
9
9
3
1
Flow value = 19Cut capacity = 19
![Page 43: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/43.jpg)
36
Augmenting Path Algorithm
Augment(f, c, P) {
b ! bottleneck(P)
foreach e " P {
if (e " E) f(eR) ! f(e) + b
else f(eR) ! f(e) - b
}
return f
}
Ford-Fulkerson(G, s, t, c) {
foreach e " E f(e) ! 0
Gf ! residual graph
while (there exists augmenting path P) {
f ! Augment(f, c, P)
update Gf }
return f
}
forward edge
reverse edge
![Page 44: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/44.jpg)
37
Max-Flow Min-Cut Theorem
Augmenting path theorem. Flow f is a max flow iff there are no
augmenting paths.
Max-flow min-cut theorem. [Ford-Fulkerson 1956] The value of the
max flow is equal to the value of the min cut.
Proof strategy. We prove both simultaneously by showing the TFAE:
(i) There exists a cut (A, B) such that v(f) = cap(A, B).
(ii) Flow f is a max flow.
(iii) There is no augmenting path relative to f.
(i) ! (ii) This was the corollary to weak duality lemma.
(ii) ! (iii) We show contrapositive.
! Let f be a flow. If there exists an augmenting path, then we can
improve f by sending flow along path.
![Page 45: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/45.jpg)
38
Proof of Max-Flow Min-Cut Theorem
(iii) ! (i)
! Let f be a flow with no augmenting paths.
! Let A be set of vertices reachable from s in residual graph.
! By definition of A, s " A.
! By definition of f, t # A.
v( f ) = f (e)e out of A
! " f (e)e in to A
!
= c(e)e out of A
!
= cap(A,B)
original network
s
t
A B
![Page 46: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/46.jpg)
39
Running Time
Assumption. All capacities are integers between 1 and C.
Invariant. Every flow value f(e) and every residual capacities cf (e)
remains an integer throughout the algorithm.
Theorem. The algorithm terminates in at most v(f*) ! nC iterations.
Pf. Each augmentation increase value by at least 1. !
Corollary. If C = 1, Ford-Fulkerson runs in O(mn) time.
Integrality theorem. If all capacities are integers, then there exists a
max flow f for which every flow value f(e) is an integer.
Pf. Since algorithm terminates, theorem follows from invariant. !
![Page 47: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/47.jpg)
7.3 Choosing Good Augmenting Paths
![Page 48: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/48.jpg)
41
Ford-Fulkerson: Exponential Number of Augmentations
Q. Is generic Ford-Fulkerson algorithm polynomial in input size?
A. No. If max capacity is C, then algorithm can take C iterations.
s
1
2
t
C
C
0 0
0 0
0
C
C
1 s
1
2
t
C
C
1
0 0
0 0
0X 1
C
C
X
X
X
1
1
1
X
X
1
1X
X
X
1
0
1
m, n, and log C
![Page 49: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/49.jpg)
42
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
! Some choices lead to exponential algorithms.
! Clever choices lead to polynomial algorithms.
! If capacities are irrational, algorithm not guaranteed to terminate!
Goal: choose augmenting paths so that:
! Can find augmenting paths efficiently.
! Few iterations.
Choose augmenting paths with: [Edmonds-Karp 1972, Dinitz 1970]
! Max bottleneck capacity.
! Sufficiently large bottleneck capacity.
! Fewest number of edges.
![Page 50: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/50.jpg)
43
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 51: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/51.jpg)
44
Capacity Scaling
Scaling-Max-Flow(G, s, t, c) {
foreach e ! E f(e) " 0
# " smallest power of 2 greater than or equal to C
Gf " residual graph
while (# $ 1) {
Gf(#) " #-residual graph
while (there exists augmenting path P in Gf(#)) {
f " augment(f, c, P)
update Gf(#)
}
# " # / 2
}
return f
}
![Page 52: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/52.jpg)
45
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 53: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/53.jpg)
46
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.
! L2 % v(f*) # v(f) + m (2$).
! Each augmentation in a $-phase increases v(f) by at least $. !
Theorem. The scaling max-flow 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 54: CSE 202 Network flow - UCSD Mathematicsfan/teach/202/notes/07maxflow15.pdf · Maximum Flow and Minimum Cut Max flow and min cut.! Two very rich algorithmic problems.! Cornerstone](https://reader036.vdocuments.us/reader036/viewer/2022070814/5f0d8ae17e708231d43ae0ab/html5/thumbnails/54.jpg)
47
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. (almost identical to proof of max-flow min-cut theorem)
! We show that at the end of a !-phase, there exists a cut (A, B)
such that cap(A, B) " v(f) + m !.
! Choose A to be the set of nodes reachable from s in Gf(!).
! By definition of A, s # A.
! By definition of f, t $ A.
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