maximum flow. p2. maximum flow a flow network g=(v, e) is a directed graph where each has a...
TRANSCRIPT
p2.
Maximum FlowA flow network G=(V, E) is a DIRECTED graph where
each has a nonnegative capacity
( , )c u v 0edge (u,v) E
( ( , ) , if (u,v) E)c u v 0
, : : source vertex sink vertexs t V s t
: ,A flow in G is a real-valued function: satisfying:f V V R
( , ) ( , )
( , ) ( , )
-{ , } ( , )v V
V f u v c u v
V f u v f v u
V s t f u v
1) Capacity constraint: u,v ,
2) Skew symmetry: u,v ,
3) Flow conservation: u , 0
| | ( , ) : value of a flow v V
f f s u f
u( , )f u V 0
p3.
Maximum-flow problemGiven a flow network G with source s and sink t, we wish to find a flow of maximum value from s to t
s
v4v2
v3v1
t
16
13
10 49
12
7
14
4
2011
8
1
12
4
11
7
15
4
p4.
positive net flow entering a vertex v:
Networks with multiple source and sinks:
, ( , )
( , )u V f u v
f u v
0
s1
s’
s2
s3
s4
s5
t3
t1
t2t’
s1
s2
s3
s4
s5
t3
t1
t2
p5.
Lemma 1
, , ( , ) ( , ) x X y Y
X Y V f X Y f x y
( , ) :
( , )( , ) ( , )
,( , ) ( , ) ( , ),( , ) ( , ) ( , )
flow network: a flow in G
. For X V,
. For X,Y V,
. For X, Y, Z V with X and
G V Ef
f X Xf X Y f Y X
Yf X Y Z f X Z f Y Zf Z X Y f Z X f Z Y
0
| | ( , )( , ) ( , )( , ) ( , ) ( , )( , )
= = =
f f s Vf V V f V s Vf V V s f V t f V V s tf V t
flow conservation
{ } ( )V s V s
( , )u V s t
f V u
X
YZ
1
2
3
4
X Y
( , ) ( , )( , ) ( , )
f ff f
1 3 1 42 3 2 4
p6.
Lester Randolph Ford, Jr. (born September 23, 1927) is an American mathematicianDelbert Ray Fulkerson (August 14, 1924 - January 10, 1976)
Ford-Fulkerson method
Residual networks
fp
f pf
Ford-Fulkerson-Method(G, s, t){ initialize flow to 0; there exists an augmenting path while
doretur
augment flow along n }
,( , ) ( , ) ( , )
( , ),{( , ) : ( , ) }
| | | |, , ,
Residual capacity of ( ) The residual network of induced by f is : where
( ) or ( )
f
f f
f f
f f
u vc u v c u v f u v
GG V EE u v V V c u v
E E u v E v u E
0
2
( , )(Given a flow network and a flow )
G V Ef
s
v4v2
v3v1
t
11/16
8/13
10 1/4 4/9
12/12
7/7
11/14
4/4
15/20(a)
Flow network
s
v4v2
v3v1
t
5
8
11 3 5
12
7
4
5(b)
Residual network
11 4 15
3
11
5
s
v4v2
v3v1
t
11/16
12/13
10 1/4 9
12/12
7/7
11/14
4/4
19/20(c)
Flow network
s
v4v2
v3v1
t
5
12
11 3 9
12
7
4
1(d)
Residual network
11 19
3
11
1
p9.
Lemma 2
'( ')( , ) ( , ) '( , )
' | | | | ' |
Let be a flow of a flow network and bethe residual network of induced by
Let be a flow in , then the flow sum is a flow in with value
|
f
f
f G GG f
f Gf f u v f u v f u v Gf f f f
( )
( ')( , )
( , ) '( , )
( , ) '( , )
( ( , ) '( , ))
( ')( , )
f f u v
f u v f u v
f v u f v u
f v u f v u
f f v u
1 ( )
'( , ) ( , )
( ')( , )
( , ) '( , )
( , ) ( ( , ) ( , ))
( , )
ff u v c u v
f f u v
f u v f u v
f u v c u v f u v
c u v
2 ( ) { , }
( ')( , )
( ( , ) '( , ))
( , ) '( , )
v V
v V
v V v V
u V s t
f f u v
f u v f u v
f u v f u v
3
0 0 0
Pf:
| ' | ( ')( , ) ( , ) '( , ) | | | ' |u V u V u V
f f f f s v f s v f s v f f
p10.
Augmenting paths (special paths):Given a flow network G=(V,E) and a flow f an augmenting path p is a simple path from s to t in the residual network Gf
( ) min{ ( , ) : ( , ) } is on f fc p c u v u v presidual capacity of :p the max amount of net flow that
can be shipped along the edges of p
p11.
Lemma3:
Cor4:
:( ) ( , ) ,
( , ) - ( ) ( , ) ,
| ( )
f
p
p f p
Let p be an augment path in GDefine by
if f if
otherwise
Then, f is a flow in G with value |f
p
f
f
f
f V V Rc p u v p
u v c p v u p
c p
0
0
' : ' '| ' | | | | | | |
Let be defined as above. Define a function by . Then, is a flow
in with value
p
p
p
ff V V R f f f fG f f f f
s
v4v2
v3v1
t
11/16
13
7/10 4 4/9 7/7
11/14
4/4
7/20
4/12
(b)
s
v4v2
v3v1
t
12
13
10 4 5
8
7
4
204
10
4
4
4
(c)
s
v4v2
v3v1
t
11/16
8/13
10 1/4 4/9 7/7
11/14
4/4
15/20
12/12
s
v4v2
v3v1
t
5
13
3 11 5
8
7
4
1311
7
3
4
4
11
(d)
s
v4v2
v3v1
t
11/16
12/13
10 1/4 9 7/7
11/14
4/4
19/20
12/12
s
v4v2
v3v1
t
5
13
3 3 5
12
7
4
511
15
3
5
4
11
The basic Ford-Fulkerson algorithm
)f
Ford-Fulkerson(G, s, t){ for each edge(u,v) E[G] do f[u,v] 0 f[v,u] 0 while (there exists a path p from s to t in the residual network G do {
( ) min{ ( , ) : ( , )
( )
f f
f
c c is in p} for each edge(u,v) in p do f[u,v] f[u,v]+c f[v,u] f[u,v] }}
p u v u v
p
Note: If the augmenting paths are chosen poorly the algorithm may not terminate.
If all the capacity is integeral, then a straightforward implementation runs inO(E|f*|), where f* is the max. flow
s tM
M
M
M
1
p18.
Edmonds-Karp algorithmImplement the computation of the augmenting path p
with a breadth-first search.
That is the augmenting path is a shortest path from s to t in the residual network, where each edge has unit distance.
p19.
Cuts of flow networks A cut(S,T) of flow network G=(V,E) is a partition of V
into S and T=V-S such that The net flow across the cut(S,T) is defined to be
f(S,T). The capacity of the cut(S,T) is c(S,T) Eg:
and s S t T
s
v4v2
v3v1
t
16
13
10 4 9
12
7
14
4
20
S T
p20.
Lemma 5Let (S,T) be a cut of a flow network G with flow f.Then the net flow across (S,T) is f(S,T)=|f|
f(S,T)=f(S, V)-f(S,S) =f(S, V) =f(s, V)+f(S-s, V) =f(s, V) = | f |
Pf:
p21.
Cor6The value of any flow f in a flow network G isbounded from above by the capacity of any cutof G
u S v T u S v T
Let (S,T) be any cut of G and f be any flow.By the above lemma and capacity constraints |f| = f(S,T) = f(u,v) c(u,v) c(S,T)
Pf:
p22.
Thm7 (Max-flow min-cut theorem)If f is a flow in a flow network G=(V,E) with sources and sink t, then the following conditions are equivalent:
f
1. f is a maximum flow in G2. The residual network G contains no augmenting path3. | f | = c(S,T) for some cut(S,T) of G
f
p
(1) (2) By contradiction, suppose f is a maximum flow in G but that G has an augment path p By cor4, the flow sum f+f is a flow in G with value strictly greater than | f |.
Pf:
p23.
},
f f
f
(2) (3) Suppose G has no augmenting path, that is, that G has no path from s to t Define S={v V: a path from s to v in G and T=V-S The partition (S,T) is a cut: we have s S trivi
.f
f
ally and t S there is no path from s to T in G For each pair of vertices u S and v T, we have f(u,v)=c(u,v) otherwise (u, v) E and v is in set S. By lemma5, | f | = f(S,T)=c(S,T)
(3) (1) By cor6, | f | c(S,T), for all cuts(S,T). The condition | f |=c(S,T) thus implies that f is a maximum flow
p24.
Thm 7.2. If all the capacities in a flow network are integers, then there is a maximum flow f for which f(e) is an integer for all edge e.
Thm 7.3. Let A be a b × v (0,1)-matrix with k 1’s per row and r 1’s per column (so bk=vr).
Let R be a rational number, 0<R<1, such that k’=Rk and r’=Rr are integers.
Then there is a (0,1)-matrix A’ of size b × v with k’ 1’s per row and r’ 1’s per column such that A’ is obtained from A by changing some 1’s into 0’s.
p25.
b=6, v=3, k=2, r=4, k’=1, r’=2 1 1 0 1 1 0 A = 0 1 1 0 1 1 1 0 1 1 0 1
1 0 0 0 1 0 A’= 0 1 0 0 0 1 1 0 0 0 0 1
2
4
1
1
2
p26.
Proof of Thm 7.3.Construct a flow network from A with s and t and associate a
vertex with each row and column.
There is a max flow with all edges saturated. Change the capacities from k to k’ and r to r’.All the capacities are integers and there is a max flow for
which all f(xi,yj)=R.
By Thm 7.2 there exists an integer max flow, such that f*(xi,yj)= 0 or 1. From this max flow, we find the required A’. □
st
x1
xb
y1
yv
k
k
1r
r
c(xi,yj)=1 iff aij =1.
p27.
Def: A circulation on a digraph D is a mapping f from E(D) to the reals satisfying conservation of flow at every vertex.
Thm 7.4. Let f be a circulation on a finite graph D. Then there exists an integral circulation g such that for every edge e, g(e) is equal to one of f(e) or f(e).
Pf: Given a circulation f, consider a circulation g satisfying (*) f(e) g(e) f(e) and for which the number of edges e with g(e) an integer is as large as possible.
Let H be the spanning subgraph of D with edge set consisting of those edges of D for which g(e) is not an integer.
p28.
Proof continueConservation of flow implies that no two vertex can have degree 1 in H, so if g is not integral, then H contains a cycle. Let P be a polygon in H and traverse P with a simple closed path; let A be the set of edges of P that are forward edges of the path in D, and B the set of edges of P that are backward edges in this path.
For any constant c, we obtain a new circulation g’:
g’(e) = (1) g(e)+c if e is in A, or
(2) g(e)-c if e is in B, or
(3) g(e) if e is not in E(P). If c is small then (*) still hold
with g replaced by g’.
Choose c= min{ min e in A ( f(e) -g(e)), min e in B ( g(e)- f(e))}. Then g’ still satisfies (*), yet g’(e) is an integer for at least one more edge. Contradict the choice of g.
+c
- c
- c
Corollary: Let f be an integral circulation on a finite digraph D and d any positive integer. Then f can be written as the sum g1+g2+...+gd of integral circulations such that for each index j and each edge e, (**) f(e)/d gj(e) f(e)/d.
Pf: By induction on d. For d=1, trivial.
Given d2, apply Thm 7.4 to f/d to find an integral circulation g1 satisfying (**) for j=1. Apply the induction hypothesis to find f - g1=g2+...+gd where for each j=2,...,d, gj is an integral circulation satisfying
(f(e)-g1(e))/(d-1) gj(e) (f(e)-g1(e))/(d-1) .
It is easy to see that if a is an integer and b is either a/d or a/d, then a/d (a-b)/(d-1) and (a-b)/(d-1) a/d, so that the above inequalities imply (**) for j=2,3,...,d. □
Thm 7.5: (1) Given a matrix A and a real number c, there is an integral matrix B so that the entries of B, the row-sums of B, the column-sums of B and the sum of all entries of B, are the corresponding values for cA rounding up or down.
(2) If A is an integral matrix and d any positive integer, then A= B1+...+Bd, where each Bi is an integral matrix whose entries , row-sums, column-sums, and sum of all entries, are those of (1/d)A, rounding up or down.
0 0 -1.5 2A= 1 2.1 0 0.2 0 -1 1.4 -0.2
0 0 -2 2B= 1 2 0 0 0 -1 2 0
st
0.5
3.3
0.2
-1.5
2
1
1.1
-0.1
2
1
2.1
0.2
-11.4
-0.2
4