Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
Fall’19 CSCE 629
Analysis of Algorithms
W, 10/23/19
Lecture 21
• Ford-Fulkerson algorithm
Credit: based on slides by A. Smith & K. Wayne
Guest lecture by Prof. Klappenecker
Recap: residue graph
§Original edge: ! = #, % ∈ '• Flow ((!), capacity +(!)
1
# %17/6Capacity Flow
§ Residual edge: “Undo” flow sent• ! = (#, %) and !/ = %, #• Residual capacity
# %
Residual Capacity
11
6
Residual capacity
+0 ! = 1+ ! − ( ! 3( ! ∈ '( ! 3( !/ ∈ '
§ Residual graph 40,5 = (6, '0,5)• Residual edges with positive residual capacity• '0,5 = !: ( ! < + ! ∪ {!/: ( ! > 0}
§ Augmenting path. Simple path > ↝ @ in residual graph 40. • Bottleneck capacity of an augmenting path A: minimum residual capacity of any edge in A.
Recap: Augmenting path theorem
2
Theorem. ! is a max flow iff. no augmenting paths (" ↝ $) in %&.
Proof. We show that the following are equivalent (' ⇒ ) ⇒ * ⇒ ')a. ! is a max flowb. There is no augmenting path (with respect to !)c. There exists a cut (,, .) such that *'0 ,, . = 2(!)
Max-flow min-cut theoremValue of max flow = capacity of min cut
a ⇔ c
Recap: proof of augmenting path theorem
3
§ a ⇒ b. We show contrapositive ¬b ⇒ ¬&
' ← bottleneck capacity of augmenting path P
For each ) ∈ +, ,′ ) = /,()) + ', ) ∈ 4,()) − ', )6 ∈ 4Pf.
• Exercise. Verify ,′ is a feasible flow (i.e., capacity and conservation hold).• 7 ,′ = 7 , + ' > 7(,) because only first edge in + leaves 9.
Lemma 1 (Augmented flow). Let + be an augmenting path with respect to ,. Then ,′ below is a feasible flow with 7 ,: > 7(,).
a. , is a max flowb. There is no augmenting path (with respect to ,)c. There exists a cut (;, <) such that =&> ;, < = 7(,)
Ford-Fulkerson augmenting-path algorithm
4
!"#$%&'(), +, ,). ← bottleneck capacity of PFor each 0 ∈ ,
If 0 ∈ 2 )3 0 = ) 0 + .
Else )3 06 = ) 06 − .return )3
89:;−8"<=%:>9&(?, @, A, +)
For each 0 ∈ 2 ) 0 ← 0, ?C ← D0@EFGHI JDHKℎ
While there is an augmenting path , in ?C) ← MGJN0OA(), +, ,)
Update ?Creturn )
Ford-Fulkerson Algorithm demo0
5
s 3
2
t
4
10 2 84
10106
59 10
(Capacity
Ford-Fulkerson algorithm demo1
6
s 3
2
t
4
10/0 2/0 8/04/0
10/0
10/06/059/0 10/0
)Flow
Capacity* + = 0
s 3
2
t
4
10 2 84
10
10659 10
Residual graph )- Residual Capacity
An augmenting path: . − 2 − 5 − 1, 2 = 8
Ford-Fulkerson algorithm demo2
7
s 3
2
t
4
10/$ 2/0 8/$4/0
10/0
10/06/059/0 10/$
*+ , = 8
s 3
2
t
4
. 2 $4
10
10659/0 .
*/$
$
An augmenting path: 0 − 2 − 3 − 5 − 4, 5 = 2
Ford-Fulkerson algorithm demo3
8
s 3
2
t
4
10/$% 2/' 8/)4/0
10/0
10/06/059/' 10/$%
-. / = 10
s 3
2
t
4
' )4
10
10651
-2$%
$%'
An augmenting path: 3 − 3 − 5 − 4 − 7, 8 = 6
Ford-Fulkerson algorithm demo4
9
s 3
2
t
4
10/$% 2/' 8/)4/0
10/+
10/+6/+59/) 10/$%
./ 0 = 16
s 3
2
t
4
' )4
22+
51
.3$%
$%)+
+
An augmenting path: 4 − 3 − 2 − 4 − 7, 8 = 2
An augmenting path: ! − 3 − 5 − 2 − 4 − ', ( = 1
Ford-Fulkerson algorithm demo5
10
s 3
2
t
4
10/-. 8/04/1
10/0
10/06/359/0 10/-.
56 7 = 18
s 3
2
t
4
1 01
113
51
58-.
-.00
01
2/.
Any more augmenting paths?
Ford-Fulkerson algorithm demo6
11
s 3
2
t
4
10/$% 2/% 8/(4/*
10/+
10/+6/-59/+ 10/$%
/0 1 = 19
s 3
2
t
4
3 $$
$$-
5
/4$%
$%++
+*
(
Cut (" = $, 3 , ' = (\A), ,-. ", ' = 19
Ford-Fulkerson algorithm demo7
12
s 3
2
t
4
10/34 2/4 8/74/9
10/:
10/:6/<59/: 10/34
=
> ? = 19 Is this a max flow?
Ford-Fulkerson algorithm: summary so far
13
!"#$−!&'()#*"+While you can • Greedily push flow• Update residual graph
§Correctness. Augmenting path theorem.
§ Running time. Does it terminate at all?
Ford-Fulkerson algorithm: analysis
14
§Assumption. All capacities are integers between 1 and ". § Invariant. Every flow value #(%) and every residual capacity '((%)
remains an integer throughout the algorithm.
§ Theorem. Ford-Fulkerson terminates in at most )" iterations. Pf. • Each augmentation increases flow value by at least 1.
• There are at most )" units of capacity leaving source *.
§ Integrality theorem. If all capacities are integers, then there exists a max flow # for which every flow value #(%) is an integer.
Running time + ,)" . Space +(, + )) Find an augmenting path in +(,) time (by BFS/DFS).
More to come on further concerns/improvements …