Week 11.2, Wednesday, Oct 30 - Purdue University · 2019. 10. 30. · 1 Week 11.2, Wednesday, Oct...
Transcript of Week 11.2, Wednesday, Oct 30 - Purdue University · 2019. 10. 30. · 1 Week 11.2, Wednesday, Oct...
1
Week 11.2, Wednesday, Oct 30Midterm 2 Tonght! October 30 (8-9:30PM) MTHW 210 and BRNG 2280
Friday PSO BRNG 2280 (Exam Capacity 62)All Others MTHW 210 (Exam Capacity 111)
Practice Midterm 2 & Solutions on PiazzaNo PSOs this week (Due to Midterm)
Friday PSO BRNG 2280 (Exam Capacity 62) All Others MTHW 210 (Exam Capacity 111) Focus: Dynamic Programing and Graph
Algorithms Lectures 15 to 28 No Network Flow (today’s lecture)
Same Rules as Midterm 1 Allowed to prepare 1 page of handwritten notes No calculators, phones, smartwatches etc… Make sure your writing implement shows up clearly
when scanned! Number 2 pencils work
3
Chapter 7
Network Flow
Slides by Kevin Wayne.Copyright © 2005 Pearson-Addison Wesley.All rights reserved.
4
Soviet Rail Network, 1955
Reference: On the history of the transportation and maximum flow problems.Alexander Schrijver in Math Programming, 91: 3, 2002.
5
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 …
6
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
10154
4capacity
source
sink
7
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
10154
4
Capacity = 10 + 5 + 15= 30
A
cap( A, B) = c(e)e out of A
∑
8
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4A
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
9
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
10154
4A
Capacity = 10 + 8 + 10= 28
Clicker Question
Find the minimum capacity s-t cut (A, B=V\A)
Choice A: A={s,b}, B={a,c,t}Choice B: A={s,a}, B={b,c, t}Choice C: A={s,a,b}, B={c, t}Choice D: A={s,a,b,c,t}, B={}Choice E: A={a,b}, B={s,c,t}
10
s
a
b
c
2
9
10002
100t104
11
Clicker Question
Find the minimum capacity s-t cut (A, B=V\A)
Choice A: A={s,b}, B={a,c,t}Choice B: A={s,a}, B={b,c, t}Choice C: A={s,a,b}, B={c, t}Choice D: A={s,a,b,c,t}, B={} (Not a s-t cut)Choice E: A={a,b}, B={s,c,t} (Not a s-t cut)
12
s
a
b
c
2
9
10002
100t104
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
4
0
0
0
0 0
0 4 4
00
0
Value = 40
f (e)e in to v
∑ = f (e)e out of v
∑
0 ≤ f (e) ≤ c(e)
capacityflow
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4 0
v( f ) = f (e) e out of s
∑ .
4
14
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
00
0
11
capacityflow
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
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
15
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
capacityflow
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4 0
Value = 28
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
11
1 10
3 8 8
00
0
11
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4 0
Value = 24
f (e)e out of A
∑ − f (e)e in to A
∑ = v( f )
4
A
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
1 10
3 8 8
00
0
11
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
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
18
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
00
0
11
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
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
19
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
∑ .
by flow conservation, all termsexcept v = s are 0
20
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
∑ .
Flow into s is 0
21
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
∑ .
If e=(u,v) with u and v in A then f(e) was added & subtracted in prior sum
22
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
10154
4
Capacity = 30
A
23
Weak duality. Let f be any flow. Then, for any s-t cut (A, B) we havev(f) ≤ cap(A, B).
Pf.
Flows and Cuts
s
t
A B
7
6
84
By Flow value lemma.
24
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
10154
4 0A
25
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
26
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
27
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