Max Flows and Minimum Cuts Carlo Mannino (from Geir Dahl notes) - - PowerPoint PPT Presentation

max flows and minimum cuts
SMART_READER_LITE
LIVE PREVIEW

Max Flows and Minimum Cuts Carlo Mannino (from Geir Dahl notes) - - PowerPoint PPT Presentation

Max Flows and Minimum Cuts Carlo Mannino (from Geir Dahl notes) University of Oslo, INF-MAT5360 - Autumn 2011 (Mathematical optimization) st-flow Given a directed graph D = ( V,E ) ( x , c ) 2 distinct vertices s,t V (1,1) 1 4 (2,2)


slide-1
SLIDE 1

Max Flows and Minimum Cuts

Carlo Mannino (from Geir Dahl notes)

University of Oslo, INF-MAT5360 - Autumn 2011 (Mathematical optimization)

slide-2
SLIDE 2

st-flow

Given a directed graph D = (V,E) 2 distinct vertices s,t  V s source: no edges entering s t sink: no edges outgoing from t Edge capacity function c: E  R+ }) , { \ ( ) ( ) (

) ( ) (

t s V v e x e x

v e v e

  

 

   

c x  

flow conservation constraints non-negativity and capacity constraints An st-flow is a function x: E  R, satisfying (x,c) s

1 4 t 2 3

(1,1) (2,3) (2,3) (1,1) (3,3) (1,1) (2,2) (2,2)

Obs: divx(v) = 0 for all v  s,t.

slide-3
SLIDE 3

Flow value

= flow outgoing from s ) ( div ) ( ) (

) (

s e x x val

x s e

 

VALUE of an st-flow

Hajhsas da

Let +(S) be an st-cut of D = (V,E) and x be an st-flow. Then Theorem (net st-flow through an st-cut)

) ( ) ( ) (

) ( ) (

x val e x e x

S e S e

  

 

   

Since sS and tS we have ) ( ) ( div ) ( div x val s v

x S v x

 

  

  

 

 

S v S e S e

v e x e x ) ( div ) ( ) (

) ( ) (  

The result follows from

Hajhsas da

Corollary (the flow sent by s equals the flow into t) ) ( div ) ( ) (

) (

t e x x val

x t e

   



Let +(S) be a st-cut of D = (V,E) and x be an st-flow. Then

slide-4
SLIDE 4

The maximum st-flow problem

Hajhsas da

Given a directed graph D = (V,E) with edge capacity c:ER+, source s and sink t, find an st-flow of maximum value. Maximum st-flow problem LP- program: optimum exists. We can apply simplex method. More effective combinatorial algorithms. }) , { \ ( ) ( ) (

) ( ) (

t s V v e x e x

v e v e

  

 

   

c x  

flow conservation constraints non-negativity and capacity constraints

 ) (

) ( max

s e

e x

maximize flow value

slide-5
SLIDE 5

Minimum st-cut

s

1 4 t 2 3

1 3 3 1 3 1 2 2

Let K = +(S) be an st-cut (s  S, t  S) CAPACITY of K: capc(K) = 

K e

e c ) (

capc(K) = 6

K

Hajhsas da

Given a directed graph D = (V,E) with edge capacity c:ER+, source s and sink t, find an st-cut with minimum capacity. Minimum st-cut problem Combinatorial optimization problem with linear

  • bjective function.
slide-6
SLIDE 6

Minimum st-cut

Hajhsas da

The following inequality holds: max{val(x): x is st-flow}  min{capc(K): K is st-cut} Lemma (weak max-flow min-cut property)

) ( cap ) ( ) ( ) ( ) ( ) (

) ( ) ( ) ( ) (

K e c e x e x e x x val

c S e S e S e S e

    

   

   

       

Let K = +(S) be a (minimum capacity) st-cut (s  S, t  S)

slide-7
SLIDE 7

The max-flow min-cut theorem

Hajhsas da

The value of a maximum st-flow equals the minimum st-cut capacity: max{val(x): x is st-flow} = min{capc(K): K is st-cut} Theorem (max-flow / min-cut ) The flow value is no larger than M Build graph D’ from D adding edge (t,s) Let M = min{capc(K): K is st-cut} s

t

(0,ce) Let l(t,s) = u(t,s) = M; (l,u) (M,M) D’ l(e) = 0, u(e) = c(e) for eE We show that D’, l and u satisfy Hoffman’s conditions

) ( ) ( ) (

) ( ) (

V S e u e l

S e S e

  

 

   

and D’ admits a circulation x’.

slide-8
SLIDE 8

Minimum st-cut

  • 1. If (t,s)  -(S)

s

t

(0,ce) (M,M) D’

) ( ) ( ) (

) ( ) (

V S e u e l

S e S e

  

 

   

Hoffman’s condition

  

  

  

  

(S) δ e (S) δ e (S) δ e

u(e) c(e) l(e) 0

  • 2. If (t,s)  -(S)

s  S , t  S K = +(S) is an st-cut

M e l

S e

) (

) (

M K e c e u

S e c S e

  

 

 

  ) ( ) (

) ( cap ) ( ) (

 

satisfying Hoffman’s condition There exists a circulation x in D’ with l  x  u  x(t,s) = M The restriction of x to the edges of D provides an st-flow with value M x circulation

M s t x e x e x

s e s e

   

 

 

) , ( ) ( ) (

) ( ) (  

slide-9
SLIDE 9

Augmenting paths

s

1 4 t 2 3

(1,4) (2,3) (1,3) (1,1) (2,2) (0,1) (1,2) (2,2)

D = (V,E), capacity c  RE

+, st-flow x  RE

Ex

= {e  E: xe< ue}  {e-1: e  E, 0 < xe}

Auxiliary Graph Dx = (V,Ex) x-AUGMENTING PATH: st-path P in Dx Forward edges P+ = {e  E: e  Ex} Backward edges P- = {e  E: e-1  Ex} s

1 4 t 2 3

P Dx

slide-10
SLIDE 10

The augmenting path theorem

Hajhsas da

An st-flow x is maximum if and only if Dx contains no x-augmenting path. Theorem (augmenting path theorem)

  • Proof. (Necessity) By contradiction.

Suppose x is maximum and P st-path of Dx s

1 4 t 2 3

(1,2) (2,3) (1,3) (1,1) (2,2) (0,1) (1,2) (2,2)

s

1 4 t 2 3

P Dx Let + = min{c(e)-x(e): e  P+} > 0 Let - = min{x(e): e  P-} > 0  = min{- , +} > 0 Send  units of flow on P. Obtain flow x’ x’ (e)= x(e) if e  P x(e)+  if eP+ x(e)-  if eP-

slide-11
SLIDE 11

The augmenting path theorem

  • Proof. (Necessity)

x' is a feasible st-flow (show it!) Since P is an st-path, we have:

) ( val ) ( ) ( ) ( ' ) ' ( val

) ( ) ( ) (

x e x e x e x x

s e s e s e

    

  

  

     

and x is not maximum, a contradiction. s

1 4 t 2 3

(1,4) (2,3) (1,3) (1,1) (2,2) (0,1) (1,2) (2,2)

Send  units of flow on P. Obtain flow x’ x’ (e)= x(e) if e  P x(e)+  if eP+ x(e)-  if eP- s

1 4 t 2 3

(1,2) (2,3) (1,3) (1,1) (2,2) (0,1) (1,2) (2,2) 2 2 2

slide-12
SLIDE 12

The augmenting path theorem

  • Proof. (Sufficiency)

Suppose no st-path in Dx s

1 4 t 2 3

(2,4) (2,3) (2,3) (0,1) (2,2) (0,1) (2,2) (2,2)

Then there is an empty st-cut K=+(S) in Dx s

1 4 t 2 3

P Dx (i.e. S = {wV: there is a sw-path in Dx} If D = (V,E) contains an edge (w,z) with wS to zV\S xwz = cwz (otherwise (w,z)  Ex)

 

 

 

) ( ) (

) ( ) (

S e S e

D D

e c e x

 

If D = (V,E) contains an edge (z,w) with wS to zV/S xzw = 0 (otherwise (z,w)-1 =(w,z)  Ex)

) (

) (

S e

D

e x

  

  

  

   

) ( ) ( ) (

) ( ) ( ) ( ) ( ) (

S e c S e S e

K cap e c e x e x x val

  

x is a maximum flow and K is a minimum cut S={s,1,2,4} +(S)

slide-13
SLIDE 13

Ford-Fulkerson algorithm

  • 1. Start with the zero flow x = 0
  • 2. Look for an x-augmenting path P in Dx
  • 3. if P exists, then find the maximum possible increase 

along P and augment x. Goto 2.

  • 4. if no such P exists then x is a maximum flow.

A minimum st-cut is +(S(x)) where S(x)={wV: there is a sw-path in Dx}. The algorthm can take C iterations, where C is the maximum capacity of an edge. This is not polynomial time (why?). There are more efficient versions (polynomial in |V| and |E|).

slide-14
SLIDE 14

Using LP duality to prove the same things

slide-15
SLIDE 15

The dual of max st-flow problem

}) , { \ (

) ( ) (

t s V v x x

v vw wv v wv wv

   

 

   

) ( E vw c x

vw vw

 

 

 

 

) ( ) (

max

t tv tv t vt vt

x x

 

yv zvw max -divx(t) PRIMAL (MF) DUAL max flow (DMF)

E vw vw vwz

c min

}) , { \ , , ( t s V w v E vw z y y

vw w v

     

) ( E sw z y

sw w

  

E) vs z y

vs v

    ( E) tw z y

tw w

    ( 1 E) vt z y

vt v

    ( 1 E) e ze   (  x

slide-16
SLIDE 16

The dual of max st-flow problem

By introducing ys = 0 and yt = -1 we make it less ugly (DMF)

E vw vw vwz

c min

}) , { \ , , ( t s V w v E vw z y y

vw w v

     

) ( E sw z y

sw w

  

E) vs z y

vs v

    ( E) tw z y

tw w

    ( 1 E) vt z y

vt v

    ( 1 E) e ze   (

E vw vw vwz

c min

1 ,   

t s

y y

) ( E vw z y y

vw w v

    

E) e ze   ( (DMF)

slide-17
SLIDE 17

The dual of max st-flow problem

(y* ,z*) is an optimal solution to dual if and only if (y*+1,z*) is optimal to:

E vw vw vwz

c min

1 ,   

t s

y y

) ( E vw z y y

vw w v

    

E) e ze   ( (DMF)

E vw vw vwz

c min

, 1  

t s

y y

) ( E vw z y y

vw w v

    

E) e ze   ( (DMF)

slide-18
SLIDE 18

Feasible solutions to the dual

Hajhsas da Let K = +(S) be an st-cut, let y’ be the incidence vector of S and let z’ be the incidence vector of +(S). Then (y’,z’) is feasible for (DMF) and its value is capc(K)

Theorem: of incidence vectors of st-cut

E vw vw vwz

c min

, 1  

t s

y y ) ( E vw z y y

vw w v

    

E) e ze   (

(DMF)

  • Proof. If not there exists vw  E 
  • '

' ' w v vw

y y z  y’,z’ binary , 1 ,

' ' '

  

w v vw

y y z 1 ) ( , , 1

' ' '

        

 vw w v

z S vw S w S v y y  contradiction

) ( cap

' '

K z c z c

c K vw vw vw E vw vw vw

  

 

Also

slide-19
SLIDE 19

Weak Max Flow – Min cut property (again)

Proven using LP duality Proof. f* maximum flow value, r* optimal value (DMF)  f* = r* (lp duality) f* = r* ≤ capc(K) y’, z’ incidence vectors of S, K (= +(S) )  (y’ , z’) feasible for (DMF) (y’ , z’) feasible for (DMF)  Let K = +(S)

Hajhsas da

The following inequality holds: max{val(x): x is st-flow}  min{capc(K): K is st-cut} Lemma (weak max-flow min-cut property)

) ( cap

' ' *

K z c z c r

c K vw vw vw E vw vw vw

  

 

 

slide-20
SLIDE 20

Max flow - Min cut (again)

Hajhsas da

If (DMF) has an optimal solution then it has one (y,z), with z incidence vector of st-cut +(S) and y incidence vector of S Theorem: optimal min-cut

  • Proof. Let (y,z) be optimal to (DMF). Order V = {v1, …, vn} so that

yv1 ≥ yv2 ≥ …, ≥ yvn Assume s = vp and t = vq Let Si = {v1 , …, vi } for p ≤ i ≤ q-1 (Ki = +( Si ) st-cut) v1 v2

vp vp-1 vp+1 vn vq vp+2

Kp v1 v2

vp vp-1 vp+1 vn vq vp+2

Kp+1 v1 v2

vp vq-1 vn vq

Kq-1 Since yvp = ys= 1 and yvq = yt = 0 then p < q s t

slide-21
SLIDE 21

Optimal Min cut

yv1 ≥ yv2 ≥ …, ≥ yvn s = vp and t = vq ( p < q) Let Si = {v1 , …, vi } for p ≤ i ≤ q-1 (Ki = +( Si ) st-cut) v1 v2

vp vp-1 vp+1 vn vq vp+2

Kp v1 v2

vp vp-1 vp+1 vn vq vp+2

Kp+1 v1 v2

vp vq-1 vn vq

Kq-1 Edge (vj ,vk) with j > k does not appear in K  {Kp , …, Kq-1} Edge (vj ,vk) with j ≤ p and k ≥ q appears in all K  {Kp , …, Kq-1} The other edges appear in some or none cuts {Kp , …, Kq-1} s t

slide-22
SLIDE 22

Optimal Min cut

yv1 ≥ yv2 ≥ …, ≥ yvn s = vp and t = vq ( p < q) Let Si = {v1 , …, vi } for p ≤ i ≤ q-1 (Ki = +( Si ) st-cut) v1 v2

vp vp-1 vp+1 vn vq vp+2

Kp v1 v2

vp vp-1 vp+1 vn vq vp+2

Kp+1 v1 v2

vp vq-1 vn vq

Kq-1 s t Choose an st-cut K {Kp , …, Kq-1} with Pr(Ki) = yvi – yvi+1 p ≤ i ≤ q-1

1

  • )

(

1

1

  

 

q p i i

v v v q p i v

y y y y

(OBS that yvi – yvi+1 ≥ 0 and )

) ( ) ( )) ( (

1

1 i c v q p i v c

K cap y y K cap E

i i 

 

 

The expected capacity of K is

slide-23
SLIDE 23

Optimal Min cut

   

     

      

 

E vw vw vw K vw vw v q p i v i c v q p i v c

c e c y y K cap y y K cap E

i i i i i

) ) (( ) ( ) ( )) ( (

1 1

1 1

(vj ,vr) with j > r not in K  {Kp , …, Kq-1}  ejr = 0 (vj ,vr) with j ≤ p and r≥ q appears in K  {Kp , …, Kq-1} Consider the contribution ejk to E(capc(K)) of edge (vj ,vk) (vj ,vr) with j ≤ p and p < r < q appears in K  {Kp , …, Kr}

r j q p

v v v v jr

y y y y e     1

r j r p i i

v v v v r p i v v jr

y y y y y y e       

1

(vj ,vr) with j > p and p < r < q appears in K  {Kj , …, Kq-1}

r j r j i i

v v v v r j i v v jr

y y y y y y e      

1

Easy to see that also for all remaining cases

r j

v v jr

y y e  

slide-24
SLIDE 24

Optimal Min cut

   

     

      

 

E vw vw vw K vw vw v q p i v i c v q p i v c

c e c y y K cap y y K cap E

i i i i i

) ) (( ) ( ) ( )) ( (

1 1

1 1

r j

v v jr

y y e  

*

)) ( ( r z c K cap E

vw E vw vw c

  

vw E vw vw vw w E vw v

z c c y y

 

 

  ) (

 

E vw vw w v c

c y y K cap E ) ( )) ( (

(y,z) feasible for (DMF)

) ( E vw z y y

vw w v

    

Optimal value to (DMF) since (y,z) is optimal Since E(capc(K)) is at most r*, there exists a cut in {Kp , …, Kq-1} whose value is at most r*

slide-25
SLIDE 25

Min-cost flow

The min-cost flow problem amounts in finding a flow x with given divergence b and minimum cost wTx. The problem can be written as a linear program ) (

) ( ) (

V v b x x

v v wv wv v vw vw

   

 

   

) ( E vw c x l

vw vw vw

  

E vw vw vwx

w min

(MCF) Show that if b, l, c are integer vectors and (MCF) has an

  • ptimal solution then it has an integer optimal solution

Show that if b, l, c are integer vectors then every vertex of the MCF polyhedron is integer.

slide-26
SLIDE 26

The shortest s-t path problem

4

s

1 2 t 3 5 1

  • 2

2 3 3

D = (V,E)

 x

us

us D(s)

su D(s)

+ x

su

= -1

  •  x

uv

uv D(v)

vu D(v)

+

x

vu

= 0

 x

ut

ut D(t)

tu D(t)

+

x

tu

= 1

  • v V-{s,t}

x  0 xRE min uvE wuv xuv s t The shortest s-t path problem can be written as a (MCF):

                       1 1 1 1 1 1 1 1 1 1 1 1 1 1

t t s s s 3 32 21 1 3 2 1

t s 3 2 1                           2 2 3 3 1 5 4 c

                 1 1 b

slide-27
SLIDE 27

Dual to the s-t path problem

max yt - ys yv - yu  wuv for all uvE Associate to (P) its dual problem, by introducing y RV

                               1 1 1 1 1 1 1 1 1 1 1 1 1 1

t t s s s 3 32 21 1 3 2 1

t s 3 2 1

                          2 2 3 3 1 5 4 c

                 1 1 b

max bTy AT y  w min wTx Ax =b x  0

                       1 1 1 1 1 1 1 1 1 1 1 1 1 1

t t s s s 3 32 21 1 3 2 1

t s 3 2 1

4

s

1 2 t 3 5 1

  • 2

2 3 3

D = (V,E)

slide-28
SLIDE 28

The s-t path polyhedron

The s-t path polyhedron: Qst = {xA: Mx=b, x 0} (SP) min wTx Mx=b x 0 Consider the following LP : The vertices of Qst are precisely the incidence vectors of the s-t paths in D. Theorem If (SP) has an optimal solution, then it has an optimal solution which is the incidence vector of an s-t path

slide-29
SLIDE 29

Dual to the s-t path problem

(SP) min wTx Mx=b x 0 if D has an s-t path (SP) is non-empty D contains an s-v path for every v  V Assumption (DSP) max yt - ys yv - yu  wuv for all uvE Associate to (SP) its dual problem, by introducing y V : s

1 2 t 3 4

yt ys y1 y2 y4 y3

slide-30
SLIDE 30

Minimum length s-t walk existence

Since (SP) is non-empty, (SP) has an optimal solution if and

  • nly if it is not unbounded

(SP) is not unbounded if and only if (DSP) is non-empty. (DSP) is non-empty iff D does not contain a negative length directed cycle. Theorem

slide-31
SLIDE 31

Proof of existence theorem

Let P*

u be a shortest path from s to u in D, u  V.

Let y’u = l(P*

u), for u  V. Then y’ is dual feasible. Suppose not.

Proof: If part (D does not contain a negative length dicycle)

v u P’ P*

u

P*

v

s

Let uv such that y’v – y’u > wuv l(P*

v)–l(P* u) > wuv

l(P*

v ) > wuv +l(P* u)

P’=(s,…,u,uv,v) is s-v path with l(P’)=l(P*

u)+wuv< l(P* v), contradiction

If v does not belong to P*

u=(s,…,u)

v belongs to P*

u=(s,…,v, …,u). Let P* v s-v subpath, P’ u-v subpath

P’ u v C P*

v

C Negative dicycle ! contradiction l(P*

v) > l(P* v) + l(P’) + wuv

0 > l(P’)+wuv= l(C) C= P’  {uv} is a cycle

slide-32
SLIDE 32

Proof of existence theorem

Let y’ = be a feasible dual solution Let C=(1,(1,2),2,…,k,(k,1),1) be a negative length dicycle: l(C) < 0 Proof: Only-If part (if y’ feasible, no negative dicycles in D)

k-1 k 1 2 3

y’ feasible implies y’2 – y’1  w12 y’3 – y’2  w23 y’1– y’k  wk1 0  l(C)< 0

+

contradiction! w12 w23 wk1

slide-33
SLIDE 33

Exercises

Show that for any st-flow x, we have

) (

) ( ) (

t e

e x x val

Two directed edges of the form (u,v) , (v,u) are said anti-parallel. Show how to transform an instance of max-flow problem D=(V, E), cRE into an equivalent instance D’ = (V’, E’) , c’  RE’ with no anti-parallel edges. v u Use the augmenting path theorem to give an alternative proof to the max-flow / min-cut theorem Show: if x is a maximum st-flow of D = (V,E), and all capacity are integral, then x can be taken integral. Show that the augmented flow x’ in the necessity proof of the augmenting path theorem is a (feasible) st-flow.