Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date:...
Transcript of Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date:...
Network Flow
Algorithm Design
GreedyDivide and
Conquer
DynamicProgramming
Network Flow?
Formulate problem -- -- -- --
Design algorithm easy hard hard ?
Prove correctness hard easy easy ?
Analyze running time
easy hard easy ?
Network Flow
Previous topics → design techniquesNetwork flow → a specific class of problems
Many applications“Traffic” in networks: cars/highways, packets/internet, water/pipesLess obvious: bipartite matching, airline scheduling, baseball elimination, and many, many more...
Network Flow
Goal: design and analyze algorithms for max-flow problem, then apply to solve other problems
Flows and Cuts:Soviet Rail Network, 1955
Reference: On the history of the transportation and maximum flow problems.Alexander Schrijver in Math Programming, 91: 3, 2002.
Example and definitions on board
Flow Network
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4capacity
source sink
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
source sink
flow = 4 4
44
0
0
0
0
0
0
0
0
0 0
0
Flow Network
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
source sink
flow = 4 4
44
0
0
0
0
0
0
0
0
0 0
0
value = 4
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
source sink
flow = 10 0
09
4
10
9
1
0
6
1
10
0 9
6
value = 24
Find s-t flow of maximum value.
Maximum Flow Problem
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10 15 4
4
source sink
flow = 10 1
010
5
13
9
0
0
8
3
13
0 9
9
value = 28
Augmenting Path
Augment(f, P) { b = bottleneck(P, f) foreach e = (u,v) ∈ P { if e is a forward edge f(e) = f(e) + b else let e’ = (v, u) f(e’) = f(e’) - b } return f}
// least residual capacity of any edge in P
Use path P in Gf to to update flow in G
// forward edge: increase flow
// backward edge: decrease flow
Example on board
Ford-Fulkerson Algorithm
Ford-Fulkerson(G, s, t) { foreach e ∈ E f(e) = 0 // initially, no flow Gf = copy of G // residual graph = original graph
while (there exists an s-t path P in Gf) { f = Augment(f, P) // change the flow update Gf // build a new residual graph } return f}
Repat: find an augmenting path, and augment!
Next Time
Termination and running time (easy)
Correctness: Max-Flow Min-Cut Theorem