taken from kevin wayne’s slides (princeton university) cosc 3101a - design and analysis of...
DESCRIPTION
3 n Network reliability. n Security of statistical data. n Distributed computing. n Egalitarian stable matching. n Distributed computing. n Many many more... Maximum Flow and Minimum Cut Max flow and min cut. n Two very rich algorithmic problems. n Cornerstone problem in combinatorial optimization. n Beautiful mathematical duality. Nontrivial applications / reductions. n Network connectivity. n Bipartite matching. n Data mining. n Open-pit mining. n Airline scheduling. n Image processing. n Project selection. n Baseball elimination.TRANSCRIPT
![Page 1: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/1.jpg)
Taken from Kevin Wayne’s slides (Princeton University)
COSC 3101A - Design and Analysis of Algorithms
13
Maximum Flow
![Page 2: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/2.jpg)
2
Contents
Contents. Maximum flow problem. Minimum cut problem. Max-flow min-cut theorem. Augmenting path algorithm. Capacity-scaling. Shortest augmenting path.
![Page 3: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/3.jpg)
3
Network reliability. Security of statistical data. Distributed computing. Egalitarian stable matching. Distributed computing. Many many more . . .
Maximum Flow and Minimum Cut
Max flow and min cut. Two very rich algorithmic problems. Cornerstone problem in combinatorial optimization. Beautiful mathematical duality.
Nontrivial applications / reductions. Network connectivity. Bipartite matching. Data mining. Open-pit mining. Airline scheduling. Image processing. Project selection. Baseball elimination.
![Page 4: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/4.jpg)
4
Max flow network: G = (V, E, s, t, u) . (V, E) = directed graph, no parallel arcs. Two distinguished nodes: s = source, t = sink. u(e) = capacity of arc e.
Max Flow Network
Capacity
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
![Page 5: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/5.jpg)
5
An s-t flow is a function f: E that satisfies: For each e E: 0 f(e) u(e) (capacity) For each v V – {s, t}: (conservation)
Flows
veveefef
ofout to in )()(
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
4
0
0
0
0
0 0
0 4 4
04 0
00Capacity
Flow
Ewvwve
wvfef),(: ofout
),(:)(Evwwve
vwfef),(: to in
),(:)(
![Page 6: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/6.jpg)
6
An s-t flow is a function f: E that satisfies: For each e E: 0 f(e) u(e) (capacity) For each v V – {s, t}: (conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
4
0
0
0
0
0 0
0 4 4
04 0
Value = 4
seeff
ofout )(
00Capacity
Flow
veveefef
ofout to in )()(
![Page 7: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/7.jpg)
7
An s-t flow is a function f: E that satisfies: For each e E: 0 f(e) u(e) (capacity) For each v V – {s, t}: (conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
10
6
6
11
11
1 10
3 8 8
04 0
Value = 2400
Capacity
Flow
veveefef
ofout to in )()(
![Page 8: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/8.jpg)
8
An s-t flow is a function f: E that satisfies: For each e E: 0 f(e) u(e) (capacity) For each v V – {s, t}: (conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
10
9
9
14
14
4 10
4 8 9
10 0
Value = 2800
Capacity
Flow
veveefef
ofout to in )()(
![Page 9: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/9.jpg)
9
Networks
communication
Network
telephone exchanges,computers, satellites
Nodes Arcs
cables, fiber optics,microwave relays
Flow
voice, video,packets
circuits gates, registers,processors wires current
mechanical joints rods, beams, springs heat, energy
hydraulic reservoirs, pumpingstations, lakes pipelines fluid, oil
financial stocks, currency transactions money
transportation airports, rail yards,street intersections
highways, railbeds,airway routes
freight,vehicles,passengers
chemical sites bonds energy
![Page 10: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/10.jpg)
10
An s-t cut is a node partition (S, T) such that s S, t T. The capacity of an s-t cut (S, T) is:
Min s-t cut: find an s-t cut of minimum capacity.
Cuts
TwSvEwvSe
wvueu
,),( ofout
).,(:)(
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
![Page 11: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/11.jpg)
11
An s-t cut is a node partition (S, T) such that s S, t T. The capacity of an s-t cut (S, T) is:
Min s-t cut: find an s-t cut of minimum capacity.
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 = 62
TwSvEwvSe
wvueu
,),( ofout
).,(:)(
![Page 12: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/12.jpg)
12
An s-t cut is a node partition (S, T) such that s S, t T. The capacity of an s-t cut (S, T) is:
Min s-t cut: find an s-t cut of minimum capacity.
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 = 28
TwSvEwvSe
wvueu
,),( ofout
).,(:)(
![Page 13: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/13.jpg)
13
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
fefefefseSeSe
ofout to in ofout
)()()(
Value = 24
10
6
6
10
10
0 10
4 8 8
04 0
00
![Page 14: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/14.jpg)
14
10
6
6
10
10
0 10
4 8 8
04 0
00
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
fefefefseSeSe
ofout to in ofout
)()()(
Value = 24
![Page 15: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/15.jpg)
15
10
6
6
10
10
0 10
4 8 8
04 0
0
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
fefefefseSeSe
ofout to in ofout
)()()(
Value = 24
0
![Page 16: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/16.jpg)
16
Let f be a flow, and let (S, T) be a cut. Then,
Proof by induction on |S|. Base case: S = { s }. Inductive hypothesis: assume true for |S| < k.
– consider cut (S, T) with |S| = k– S = S' { v } for some v s, t, |S' | = k-1 cap(S', T') = | f |.– adding v to S' increase cut capacity by
Flows and Cuts.)()(
to in ofout
Se Sefefef
0)()( to in ofout
veveefef
s
vt
After
s
vt
S' Before S
![Page 17: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/17.jpg)
17
L2. Let f be a flow, and let (S, T) be a cut. Then, | f | cap(S, T).
Proof.
Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), then f is a max flow and (S, T) is a min cut.
Flows and Cuts
T)cap(S,
)(
)(
)()(
ofout
ofout
to in ofout
Se
Se
SeSe
eu
ef
efeff
s
t
S T
76
84
![Page 18: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/18.jpg)
18
Max Flow and Min Cut
Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), then f is a max flow and (S, T) is a min cut.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
10
9
9
15
15
4 10
4 8 9
10 0
Flow value = 28
00
Cut capacity = 28
![Page 19: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/19.jpg)
19
Max-Flow Min-Cut Theorem
MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): In any network, the value of the max flow is equal to the value of the min cut.
"Good characterization." Proof IOU.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
10
9
9
15
15
4 10
4 8 9
10 0
Flow value = 28
00
Cut capacity = 28
![Page 20: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/20.jpg)
20
Towards an Algorithm
Find an s-t path where each arc has u(e) > f(e) and "augment" flow along the path.
s
4
2
5
3 t
4
0 0
0 0 0
0
40
4 4
Flow value = 0
10 13 10
![Page 21: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/21.jpg)
21
Towards an Algorithm
Find an s-t path where each arc has u(e) > f(e) and "augment" flow along the path.
Repeat until you get stuck.
s
4
2
5
3 t
4
0 0
0 0 0
0
40
4 4
Flow value = 10
10 13 1010 10 10X X X
![Page 22: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/22.jpg)
22
Towards an Algorithm
Find an s-t path where each arc has u(e) > f(e) and "augment" flow along the path.
Repeat until you get stuck. Greedy algorithm fails.
s
4
2
5
3 t 10 13 10
4
0 0
10 10 10
0
40
4 4
Flow value = 10
s
4
2
5
3 t 10 13 10
5
4 4
10 6 10
4
54
5 5
Flow value = 14
![Page 23: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/23.jpg)
23
Residual Arcs
Original graph G = (V, E). Flow f(e). Arc e = (v, w) E.
Residual graph: Gf = (V, Ef ). Residual arcs e = (v, w) and eR = (w, v). "Undo" flow sent.
v w 176
Capacity
Flow
v w 11
Residual capacity
6Residual capacity
![Page 24: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/24.jpg)
24
Residual Graph and Augmenting Paths
Residual graph: Gf = (V, Ef ). Ef = {e : f(e) < u(e)} {eR : f(e) > 0}.
s
4
2
5
3 t 10 13 10
4
0 0
10 10 10
0
40
4 4
s
4
2
5
3 t 10 10 10
4 4
4 4
3
Ee
Eeefeueu Rf iff(e)
if)()()(
G
Gf
![Page 25: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/25.jpg)
25
Augmenting Path
Augmenting path = path in residual graph.
s
4
2
5
3 t 10 13 10
4
0 0
10 10 10
0
40
4 4
s
4
2
5
3 t 10 10 10
4 4
4 4
3
G
Gf
4 4
6
4
4
X
X
X
X
X
![Page 26: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/26.jpg)
26
Augmenting Path
Augmenting path = path in residual graph. Max flow no augmenting paths ???
s
4
2
5
3 t 10 13 10
4
4 4
10 6 10
4
44
4 4
s
4
2
5
3 t 10 6 10
4 4
4 4
7
Flow value = 14
G
Gf
![Page 27: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/27.jpg)
27
Max-Flow Min-Cut Theorem
Augmenting path theorem (Ford-Fulkerson, 1956): A flow f is a max flow if and only if 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.
We prove both simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = cap(S, T).
![Page 28: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/28.jpg)
28
Proof of Max-Flow Min-Cut Theorem
We prove both simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = cap(S, T).
(i) (ii)
We show contrapositive. Let f be a flow. If there exists an augmenting path, then we can
improve f by sending flow along path.
(iii) (i) Next slide.
(iii) (i) This was the Corollary to Lemma 2.
![Page 29: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/29.jpg)
29
Proof of Max-Flow Min-Cut Theorem
We prove both simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = cap(S, T).
(ii) (iii) Let f be a flow with no augmenting paths. Let S be set of vertices reachable from s in residual graph.
– clearly s S, and t S by definition of f
T)(S,
)(
)()(
ofout
to in ofout
cap
eu
efeff
Se
SeSe
s
t
Original Network
S T
![Page 30: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/30.jpg)
30
Augmenting Path Algorithm
b bottleneck(P) FOREACH e P IF (e E) // forward arc f(e) f(e) + b ELSE // backwards arc f(eR) f(e) - bRETURN f
Augment (f, P)
FOREACH e E f(e) 0Gf residual graph
WHILE (there exists augmenting path P) f augment(f, P) update GfRETURN f
FordFulkerson (V, E, s, t)
![Page 31: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/31.jpg)
31
Running Time
Assumption: all capacities are integers between 0 and U.
Invariant: every flow value f(e) and every residual capacities uf (e) remains an integer throughout the algorithm.
Theorem: the algorithm terminates in at most | f * | nU iterations.
Corollary: if U = 1, then algorithm runs in O(mn) time.
Integrality theorem: if all arc capacities are integers, then there exists a max flow f for which every flow value f(e) is an integer.
Note: algorithm may not terminate on some pathological instances (with irrational capacities). Moreover, flow value may not even converge to correct answer.
![Page 32: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/32.jpg)
32
1000
0
s
4
2
t 1
100
100
0
0
0
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
100
![Page 33: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/33.jpg)
33
1000
0
s
4
2
t 1
100
100
0
0
0
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
100
1
1
1
X
X
X
![Page 34: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/34.jpg)
34
1001
0
s
4
2
t
100
1
1
0
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
100
100
1
![Page 35: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/35.jpg)
35
1001
0
s
4
2
t 1
100
100
1
1
0
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
100
1
0
1
X
X
X
![Page 36: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/36.jpg)
36
s
4
2
t 1
100
100 100
100
0
1
1 1
1
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
200 iterations possible.
![Page 37: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/37.jpg)
37
Choosing Good Augmenting Paths
Use care when selecting augmenting paths. Some choices lead to exponential algorithms. Clever choices lead to polynomial algorithms.
Goal: choose augmenting paths so that: Can find augmenting paths efficiently. Few iterations.
Edmonds-Karp (1972): choose augmenting path with Max bottleneck capacity. (fat path) Sufficiently large capacity. (capacity-scaling) Fewest number of arcs. (shortest path)
![Page 38: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/38.jpg)
38
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 39: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/39.jpg)
39
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 .
FOREACH e E, f(e) 0 smallest power of 2 greater than or equal to U
WHILE ( 1) Gf() -residual graph WHILE (there exists augmenting path P in Gf()) f augment(f, P) update Gf() / 2 RETURN f
ScalingMaxFlow(V, E, s, t)
![Page 40: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/40.jpg)
40
Capacity Scaling: Analysis
L1. If all arc capacities are integers, then throughout the algorithm, all flow and residual capacity values remain integers.
Thus, = 1 Gf() = Gf , so upon termination f is a max flow.
L2. The outer while loop repeats 1 + log2 U times. Initially U < 2U, and decreases by a factor of 2 each iteration.
L3. Let f be the flow at the end of a -scaling phase. Then value of the maximum flow is at most | f | + m .
L4. There are at most 2m augmentations per scaling phase. Let f be the flow at the end of the previous scaling phase. L3 |f*| | f | + m (2). Each augmentation in a -phase increases | f | by at least .
Theorem. The algorithm runs in O(m2 log (2U) ) time.
![Page 41: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/41.jpg)
41
Capacity Scaling: Analysis
L3. Let f be the flow at the end of a -scaling phase. Then value of the maximum flow is at most |f| + m .
We show that at the end of a -phase, there exists a cut (S, T) such that cap(S, T) | f | + m .
Choose S to be the set of nodes reachable from s in Gf().– clearly s S, and t S by definition of S
mΔ-T)cap(S,
eu
eu
efeff
SeSeSe
SeSe
SeSe
to in ofout ofout
to in ofout
to in ofout
)(
))((
)()(
s
t
Original Network
S T
![Page 42: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/42.jpg)
42
Choosing Good Augmenting Paths
Use care when selecting augmenting paths. Some choices lead to exponential algorithms. Clever choices lead to polynomial algorithms.
Goal: choose augmenting paths so that: Can find augmenting paths efficiently. Few iterations.
Edmonds-Karp (1972): choose augmenting path with Max bottleneck capacity. (fat path) Sufficiently large capacity. (capacity-scaling) Fewest number of arcs. (shortest path)
![Page 43: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/43.jpg)
43
Shortest Augmenting Path
Intuition: choosing path via breadth first search. Easy to implement.
– may implement by coincidence! Finds augmenting path with fewest number of arcs.
FOREACH e E f(e) 0Gf residual graph
WHILE (there exists augmenting path) find such a path P by BFS f augment(f, P) update GfRETURN f
ShortestAugmentingPath(V, E, s, t)
![Page 44: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/44.jpg)
44
Shortest Augmenting Path: Overview of Analysis
L1. Throughout the algorithm, the length of the shortest path never decreases.
Proof ahead.
L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases.
Proof ahead.
Theorem. The shortest augmenting path algorithm runs in O(m2n) time.
O(m+n) time to find shortest augmenting path via BFS. O(m) augmentations for paths of exactly k arcs. If there is an augmenting path, there is a simple one.
1 k < n O(mn) augmentations.
![Page 45: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/45.jpg)
45
Shortest Augmenting Path: Analysis
Level graph of (V, E, s). For each vertex v, define (v) to be the length (number of arcs) of
shortest path from s to v. LG = (V, EG) is subgraph of G that contains only those arcs
(v,w) E with (w) = (v) + 1.
s
2
3
5
6 t
s
2
3
5
6 t
= 0 = 1 = 2 = 3
LG:
G:
![Page 46: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/46.jpg)
46
Shortest Augmenting Path: Analysis
Level graph of (V, E, s). For each vertex v, define (v) to be the length (number of arcs) of
shortest path from s to v. L = (V, F) is subgraph of G that contains only those arcs
(v,w) E with (w) = (v) + 1. Compute in O(m+n) time using BFS, deleting back and side arcs. P is a shortest s-v path in G if and only if it is an s-v path L.
s
2
3
5
6 t
= 0
= 1
= 2
= 3
L:
![Page 47: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/47.jpg)
47
Shortest Augmenting Path: Analysis
L1. Throughout the algorithm, the length of the shortest path never decreases.
Let f and f' be flow before and after a shortest path augmentation. Let L and L' be level graphs of Gf and Gf '
Only back arcs added to Gf '
– path with back arc has length greater than previous length
s
2
3
5
6 t
= 0 = 1 = 2 = 3
L
s
2
3
5
6 t
L'
![Page 48: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/48.jpg)
48
Shortest Augmenting Path: Analysis
L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases.
At least one arc (the bottleneck arc) is deleted from L after each augmentation.
No new arcs added to L until length of shortest path strictly increases.
s
2
3
5
6 t
= 0 = 1 = 2 = 3
L
s
2
3
5
6 t
L'
![Page 49: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/49.jpg)
49
Shortest Augmenting Path: Review of Analysis
L1. Throughout the algorithm, the length of the shortest path never decreases.
L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases.
Theorem. The shortest augmenting path algorithm runs in O(m2n) time.
O(m+n) time to find shortest augmenting path via BFS. O(m) augmentations for paths of exactly k arcs. O(mn) augmentations.
Note: (mn) augmentations necessary on some networks. Try to decrease time per augmentation instead. Dynamic trees O(mn log n) Sleator-Tarjan, 1983 Simple idea O(mn2)
![Page 50: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/50.jpg)
50
Shortest Augmenting Path: Improved Version
Two types of augmentations. Normal augmentation: length of shortest path doesn't change. Special augmentation: length of shortest path strictly increases.
L3. Group of normal augmentations takes O(mn) time. Explicitly maintain level graph - it changes by at most 2n arcs after
each normal augmentation. Start at s, advance along an arc in LG until reach t or get stuck.
– if reach t, augment and delete at least one arc– if get stuck, delete node
s
2
3
5
6 t
= 0 = 1 = 2 = 3
LG
![Page 51: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/51.jpg)
51
Shortest Augmenting Path: Improved Version
s
2
3
5
6 t
LG
s
2
3
5
6 t
LG
s
2 5
6 t
LG
augment
augment
delete 3
![Page 52: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/52.jpg)
52
Shortest Augmenting Path: Improved Version
s
2 5
6 t
LG
s
2 5
6 t
LG
STOP: length of shortest path must have strictly increased
augment
![Page 53: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/53.jpg)
53
Shortest Augmenting Path: Improved Version
ARRAY pred[v V]LG level graph of Gfv s, pred[v] nil
REPEAT WHILE (there exists (v,w) LG) pred[w] v, v w IF (v = t) P path defined by pred[] f augment(f, P) update LG v s, pred[v] nil delete v from LG UNTIL (v = s)
RETURN f
AdvanceRetreat(V, E, f, s, t)
advance
retreat
augment
![Page 54: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/54.jpg)
54
Shortest Augmenting Path: Improved Version
Two types of augmentations. Normal augmentation: length of shortest path doesn't change. Special augmentation: length of shortest path strictly increases.
L3. Group of normal augmentations takes O(mn) time. Explicitly maintain level graph - it changes by at most 2n arcs after
each normal augmentation. Start at s, advance along an arc in LG until reach t or get stuck.
– if reach t, augment and delete at least one arc– if get stuck, delete node– at most n advance steps before one of above events
Theorem. Algorithm runs in O(mn2) time. O(mn) time between special augmentations. At most n special augmentations.
![Page 55: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/55.jpg)
55
Choosing Good Augmenting Paths: Summary
First 4 rules assume arc capacities are between 0 and U.
Method AugmentationsAugmenting path nU
Max capacity m log UCapacity scaling m log U
Shortest path mn
Running timemnU
m log U (m + n log n)m2 log U
m2nImproved shortest path mn mn2
Improved capacity scaling m log U mn log U
![Page 56: Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow](https://reader035.vdocuments.mx/reader035/viewer/2022062401/5a4d1af67f8b9ab059981c50/html5/thumbnails/56.jpg)
56
History
Dantzig
Discoverer
Simplex
Method Big-Oh
mn2U1951
Year
Ford, Fulkerson Augmenting path mnU1955Edmonds-Karp Shortest path m2n1970
Dinitz Shortest path mn21970Edmonds-Karp, Dinitz Capacity scaling m2 log U1972
Dinitz-Gabow Capacity scaling mn log U1973Karzanov Preflow-push n31974
Sleator-Tarjan Dynamic trees mn log n1983Goldberg-Tarjan FIFO preflow-push mn log (n2 / m)1986
. . . . . . . . .. . .
Goldberg-Rao Length function m3/2 log (n2 / m) log Umn2/3 log (n2 / m) log U
1997