lecture20_2013

CSCI 256
Data Structures and Algorithm Analysis
Lecture 20
Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights
reserved, and some by Iker Gondra
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
10
s
5
2
9
5
4
15
15
10
3
8
6
10
4
6
15

t
A
15
4
30
7
10
Capacity = 10 + 5 + 15
= 30
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
10
5
s
A
15
2
9
5
4
15
15
10
3
8
6
10
4
6
15
4

30
7
t
10
Capacity = 9 + 15 + 8 + 30
= 62
Minimum Cut Problem
• Min s-t cut problem: Find an s-t cut of minimum
capacity
10
5
s
A
15
2
9
5
4
15
15
10
3
8
6
10
4
6
15
4
30
7
t
10
Capacity = 10 + 8 + 10
= 28
Find a Minimum Cut
u
10
40
10
s
10
t
40
v
Find a Minimum Cut
6
6
a
e
5
8
10
s
f
5
c
4
g
5
d
6
t
2
7
3
3
b
4
h
8
Interesting point
• We’ll see -- problem of finding min cut is solved
using FF technique
• Definition: the net flow across the cut = sum of
the flows out of A minus the sum of the flows
into A ( written as fout (A) –fin(A) )
Flows and Cuts
• 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:  f (e)   f (e)  v( f )
e out of A
e in to A
6
9
2
10
10
4 4
3
s
5

0
15
5
6
15
0
8
8
3
A
8
6
1
15
4 0
11
6
15 0
11
4
30
10
7
10
t
10
10
Value = 24
Flows and Cuts
• 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:  f (e)   f (e)  v( f )
e out of A
e in to A
6
9
2
10
10
4 4
3
s
5

0
15
5
6
15
0
8
8
3
A
8
6
1
15
4 0
11
6
15 0
11
4
30
10
7
10
t
10
10
Value = 6 + 0 + 8 - 1 + 11
= 24
Flows and Cuts
• 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:  f (e)   f (e)  v( f )
e out of A
e in to A
6
9
2
10
10
4 4
3
s
5

0
15
5
6
15
0
8
8
3
A
8
6
1
15
4 0
11
6
15 0
11
4
30
10
7
10
t
10
10
Value = 10 - 4 + 8 - 0 + 10
= 24
Let us see how to prove the flow value
lemma
Proof:
v(f) = f(e) = f(e) - f(e)
e out of s
(def and s is source)
e out of s e into s
= fout (s) - fin(s) (definition)
=  ( fout (v) - fin(v) ) conservation: nodes in A except s are internal
v in A
= 
(  f(e) -
v in A
e out of v
=  f(e)
e out of A
-
 f(e) ) (definition)
e into v
 f(e) = fout (A) –fin(A)
e into A
(reason for second-last equality: if e has both ends in A, f(e) appears
once with a + and once with a – and they cancel; if e has tail in A it
appears with a +; if it has its head in A it appears with a minus) .
Flows and Cuts
• Flow value lemma: Let f be any flow, and let (A,
B) be any s-t cut. Then
 f (e)   f (e)  v( f )
e out of A

e in to A
Proof: previous slide
Thus by watching the amount of flow f sends across a cut
we can measure the value of the flow – it is the amount
out minus the amount in.
Relationship of Flows and Cuts
• We shall show: Let f be any flow, and let (A, B) be any st cut. Then the value of the flow is at most the
capacity of the cut
Cut capacity = 30 
10
s
5
Flow value  30
2
9
5
4
15
15
10
3
8
6
10
4
6
15
4
30
t
A
15
7
10
Capacity = 30
Flows and Cuts
• Flow/Cut Lemma : Let f be any flow. Then, for any s-t cut
(A, B) we have v(f)  cap(A, B)
Proof: = v(f) = fout (A) - fin(A) flow value lemma (and definition)
≤ fout (A)
=  f(e)
definition
e out of A
≤  c(e)
capacity condition
e out of A
= c(A,B)
definition
The corollary below follows from the flow/cut lemma – do you
see why??? (Focus on the two any’s in the statement of the
lemma)
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 = 28
Cut capacity = 28 
Flow value  28
9
2
9
4
1
15
10
10
0
4
5
s
5
9
15
0
9
8
3
8
6
4
A
15
4 0
14
6
15 0
14
4
30
10
7
10
10
10
t
• The Ford-Fulkerson Algorithm terminates when
the flow f has no s-t path in Gf
• This is the property needed to prove its
maximality
Max-Flow = Min Cut
Theorem: If f is an s-t flow such that there is no s-t path in
Gf, then there is an s-t cut (A*,B*) for which v(f) = c(A*,B*).
Consequently, f has the maximum value of any flow in G
and (A*,B*) has the minimum capacity of any s-t cut.
Proof: The second statement is the above corollary; so all
we need to do is prove the first statement.
Assume we have an s-t flow such that there is no s-t path
in Gf.Here is how to find (A*,B*): Let A* denote the set of
nodes {v} such that there is an s-v path in Gf. Let B* = V A*.; then:
Proof of Max-Flow Min-Cut Theorem
1. (A*, B*) is a cut (Why?? --- well s is in A* and t must be
in B* as there is no s-t path in Gf)
2. If e=(u,v) is an edge in G with u in A* and v in B*, then
f(e) = c(e) (Why?? If not, e is a forward in edge in Gf and
thus there would be an s-v path in Gf – impossible as v is
in B*)
3. In a similar manner we can show that if e’ = (u’, v’) is an
edge in G with u’ in B* and v’ in A*, then f(e’) = 0 (if not
consider the backward edge (v’,u’) in Gf ; it gives rise to an
s-u’ path in Gf (via s-v’-u’) – impossible as u’ is in B*)
From 2 and 3 we conclude that all edges e out of A* are
completely saturated with flow (i.e., f(e) = c(e)) while all
edges e into A* are completely unused (i.e., f(e) = 0).
Proof of Max-Flow Min-Cut Theorem
Thus:
v(f) = fout(A*) – fin(A*) flow value lemma ((A*, B*) is a cut)
= Σ f(e) - Σ f(e)
e out of A*
definition
e into A*
= Σ c(e) - 0
previous slide justifies this
e out of A*
= c(A*,B*)
definition
Max-Flow Min-Cut Theorem
• Ford-Fulkerson algorithm finds a flow where the residual
graph Gf is disconnected, thus we can’t increase the flow
any more; hence FF finds a maximum flow.
• If we want to find a minimum cut, we begin by finding a
maximum flow. Then using the Gf obtained by FF,
perform a BFS to determine the set of nodes A* that s
can reach. If B* = V–A*, (A*,B*) is a cut of minimum
capacity.