7.1 Nework Flow
Sovie Rail Nework, 19 Reerence: On he hiory o he ranporaion and maximum low problem. lexander Schrijver in Mah Programming, 91: 3, 00. (See Exernal Link )
Maximum Flow and Minimum Cu Max low and min cu. Two very rich algorihmic problem. Cornerone problem in combinaorial opimizaion. Beauiul mahemaical dualiy. Nonrivial applicaion / reducion. Daa mining. Open-pi mining. Projec elecion. irline cheduling. Biparie maching. Baeball eliminaion. Image egmenaion. Nework conneciviy. Nework reliabiliy. Diribued compuing. Egaliarian able maching. Securiy o aiical daa. Nework inruion deecion. Muli-camera cene reconrucion. Many many more... 3
Minimum Cu Problem Flow nework. bracion or maerial lowing hrough he edge. G = (V, E) = direced graph Two diinguihed node: = ource, = ink. c(e) = capaciy o edge e. 9 ource 3 8 ink capaciy 30 7
Cu De. n - cu i a pariion (, B) o V wih and B. De. The capaciy o a cu (, B) i: cap (, B ) e ou o c(e) Q. Wha i he capaciy o he - cu ( {}, V-{} )? B 9 3 8 30 7 Capaciy = + + = 30
Cu De. n - cu i a pariion (, B) o V wih and B. De. The capaciy o a cu (, B) i: cap (, B ) e ou o c(e) Q. Wha i he capaciy o he - cu ( {,,3,}, {,,7,} )? 9 3 8 30 7 Capaciy = 9 + + 8 + 30 =
Minimum Cu Problem Min - cu problem. Find an - cu o minimum capaciy. (a boleneck) Q. Wha i he capaciy o he minimum - cu? (1 min) 9 3 8 30 7 7
Minimum Cu Problem Min - cu problem. Find an - cu o minimum capaciy. (a boleneck) Q. Wha i he capaciy o he minimum - cu? (1 min) 9 3 8 30 7 Capaciy = + 8 + = 8 8
Flow De. n - low i a uncion ha aiie: 0 (e) c(e) For each e E: (capaciy) For each v V {, }: (conervaion) e ino v ( e) e ou o v ( e) De. The value o a low i: Q. I he low below correc? v( ) (e). e ou o 0 low capaciy 9 0 0 0 0 3 8 capaciy 0 0 0 0 low 0 0 30 7 Value = 9
Flow De. n - low i a uncion ha aiie: 0 (e) c(e) For each e E: (capaciy) For each v V {, }: (conervaion) e ino v ( e) e ou o v ( e) De. The value o a low i: Q. Wha i he value o hi low? (, 30,..)? low capaciy v( ) (e). e ou o 9 0 0 3 8 8 3 8 capaciy 0 1 0 low 11 11 30 7
Flow De. n - low i a uncion ha aiie: 0 (e) c(e) For each e E: (capaciy) For each v V {, }: (conervaion) e ino v ( e) e ou o v ( e) De. The value o a low i: Q. Wha i he value o hi low? (, 30,..)? low capaciy v( ) (e). e ou o 9 0 0 3 8 8 3 8 capaciy 0 1 0 low 11 11 30 7 Value = +3+11 = 11
Maximum Flow Problem Max low problem. Find - low o maximum value. Q. Wha i he value o he maximum low here? (1 min) 9 3 8 capaciy 30 7 1
Maximum Flow Problem Max low problem. Find - low o maximum value. Q. Wha i he value o he maximum low here? (1 min) 9 9 low capaciy 1 0 0 9 8 9 3 8 capaciy 0 0 low 1 1 30 7 Value = ++1 = 8 13
Toward Solving he Maximum Flow Problem Le be any low, and le (, B) be any - cu. Flow value lemma. The ne low acro any cu i equal o low leaving. Weak dualiy. For any - cu (, B) we have v() cap(, B). Corollary. I v() = cap(, B), hen i a max low. Max-low algorihm Max-low min-cu heorem. [Ford-Fulkeron 19] The value o he max low i equal o he capaciy o he min cu. 1
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then, he ne low en acro he cu i equal o he amoun leaving. e ou o ( e) e ino ( e) v( ) 9 low capaciy 0 0 3 8 8 3 8 0 1 0 11 11 30 7 Value =
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then, he ne low en acro he cu i equal o he amoun leaving. e ou o ( e) e ino ( e) v( ) Q. Wha i he ne low en acro he cu ({,,3,}, {,,7,})? (,, or ) 9 0 0 3 8 8 3 8 0 1 0 11 11 30 7 1
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then, he ne low en acro he cu i equal o he amoun leaving. e ou o ( e) e ino ( e) v( ) Q. Wha i he ne low en acro he cu ({,,3,}, {,,7,})? (,, or ) 9 0 0 3 8 8 3 8 0 1 0 11 11 30 7 Value = + 0 + 8-1 + 11 = 17
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then, he ne low en acro he cu i equal o he amoun leaving. e ou o ( e) e ino ( e) v( ) Q. Wha i he ne low en acro he cu ({,3,,7}, {,,,})? (, 8, or 7) 9 0 0 3 8 8 3 8 0 1 0 11 11 30 7 18
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then, he ne low en acro he cu i equal o he amoun leaving. e ou o ( e) e ino ( e) v( ) Q. Wha i he ne low en acro he cu ({,3,,7}, {,,,})? (, 8, or 7) 9 0 0 3 8 8 3 8 0 1 0 11 11 30 7 Value = - + 8-0 + = 19
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then e ou o ( e) e ino ( e) v( ) P. Q. How o ar? 0
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then e ou o ( e) e ino ( e) v( ) P. v ( ) M (e) (e). e ou o e ino 1
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then e ou o ( e) e ino ( e) v( ) P. v ( ) (e) M e ou o (e) (e). e ou o e in o (e) Q. Wha do we know or node v in on: (e)? e ou o v e in o v
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then e ou o ( e) e ino ( e) v( ) P. v ( ) (e) M e ou o (e) (e). e ou o e in o Q. Wha do we know or node v in on: ( e) ( e)? e ou o v e in o v. Conervaion o low or v or : (rom deiniion o low) (e) (e) e in o v e ou o v 3
Flow and Cu Flow value lemma. Le be any low, and le (, B) be any - cu. Then e ou o ( e) e ino ( e) v( ) P. by low conervaion, all erm excep v = are 0 v ( ) (e) e ou o (e) (e) (e) e ou o v \ e ou o v e in o v (e) (e). e ou o e in o Conervaion or v, : Thi proo can be ound on page 37. (e) (e) e in o v e ou o v
Flow and Cu Q. Le be any low, and le (, B) be any - cu. Can he value o he low be more han he capaciy o he cu? 9 3 8 30 7
Flow and Cu Q. Le be any low, and le (, B) be any - cu. Can he value o he low be more han he capaciy o he cu?. No. Proo on nex lide. Cu capaciy = 30 Flow value 30 9 3 8 30 7 Capaciy = 30
Flow and Cu Weak dualiy. Le be any low. Then, or any - cu (, B) we have v() cap(, B). P. Q. How o ar? B 8 7 7
Flow and Cu Weak dualiy. Le be any low. Then, or any - cu (, B) we have v() cap(, B). P. Le a cu (,B) be given. v ( ) M 8 B cap(, B ) 7 Q. Then wha? 8
Flow and Cu Weak dualiy. Le be any low. Then, or any - cu (, B) we have v() cap(, B). P. Le a cu (,B) be given. v ( ) B M 8 c (e) e ou o Q. Then wha?. Ue deiniion o capaciy cap(, B ) 7 9
Flow and Cu Weak dualiy. Le be any low. Then, or any - cu (, B) we have v() cap(, B). P. Le a cu (,B) be given. v ( ) (e) (e) B e ou o M e in o 8 c (e) e ou o cap(, B ) 7 Q. Then wha?. Ue deiniion o capaciy. Ue previou lemma (low value lemma): (e) (e) v( ) e ou o e in o 30
Flow and Cu Weak dualiy. Le be any low. Then, or any - cu (, B) we have v() cap(, B). P. Le a cu (,B) be given. v ( ) (e) (e) B e ou o M e in o 8 c (e) e ou o cap(, B ) 7 Q. Why hould hi hold? 31
Flow and Cu Weak dualiy. Le be any low. Then, or any - cu (, B) we have v() cap(, B). P. Le a cu (,B) be given. v ( ) (e) (e) e ou o e in o e ou o e ou o (e) c (e) cap(, B ) 8 7 B Q. Why hould hi hold?. Ue imple arihmeic:. Ue deiniion (o low): (e) (e) (e) e ou o e in o e ou o 0 (e) c(e) Thi proo can be ound on page 37-38. 3
Flow and Cu Weak dualiy. Le be any low. Then, or any - cu (, B) we have v() cap(, B). P. Le a cu (,B) be given. v ( ) (e) (e) e ou o e in o e ou o e ou o (e) c (e) cap(, B ) (by low value lemma) Ue deiniion (o low): 0 (e) c(e) (by deiniion o capaciy) Thi proo can be ound on page 37-38. 33
Ceriicae o Opimaliy Q. How can we check when i a low maximal? 9 9 1 0 0 9 8 9 3 8 1 0 0 1 30 7 3
Ceriicae o Opimaliy Q. How can we check when i a low maximal?. I here i a cu (,B).. v() = cap(, B), hen i a max low. Value o low = ++1 = 8 Cu capaciy = +8+ = 8 Flow value 8 9 9 1 0 0 9 8 9 3 8 0 0 1 1 30 7 3
Ceriicae o Opimaliy Corollary. Le be any low, and le (, B) be any cu. I v() = cap(, B), hen i a max low. Value o low = ++1 = 8 Cu capaciy = +8+ = 8 Flow value 8 9 9 1 0 0 9 8 9 3 8 0 0 1 1 30 7 3
Toward a Max Flow lgorihm Q. How o ind uch a max low? (1 min) 1 0 30 0 37
Toward a Max Flow lgorihm Greedy algorihm. Sar wih (e) = 0 or all edge e E. Find an - pah P where each edge ha (e) c(e). ugmen low along pah P. Repea unil you ge uck. 1 0 0 0 30 0 0 0 0 Flow value = 0 38
Toward a Max Flow lgorihm Greedy algorihm. Sar wih (e) = 0 or all edge e E. Find an - pah P where each edge ha (e) c(e). ugmen low along pah P. Repea unil you ge uck. Q. Can he low below be improved in hi way (or are we uck)? 1 0 X 0 0 0 30 X 0 0 0 0 X 0 0 Flow value = 0 39
Toward a Max Flow lgorihm Greedy algorihm. Sar wih (e) = 0 or all edge e E. Find an - pah P where each edge ha (e) c(e). ugmen low along pah P. Repea unil you ge uck. Q. I he low below opimal? 1 0 X 0 0 0 30 X 0 0 0 0 X 0 0 Flow value = 0 0
Toward a Max Flow lgorihm Greedy algorihm. Sar wih (e) = 0 or all edge e E. Find an - pah P where each edge ha (e) c(e). ugmen low along pah P. Repea unil you ge uck. Q. How can we ix hi? (1 min) locally opimaliy global opimaliy 1 1 0 0 0 0 0 30 0 30 0 greedy = 0 0 0 op = 30 0 0 1
Toward a Max Flow lgorihm Greedy algorihm. Sar wih (e) = 0 or all edge e E. Find an - pah P where each edge ha (e) c(e). ugmen low along pah P. Repea unil you ge uck. lo allow decreaing he low on an edge ( undo ) 1 0 0 0 1 0 0 30 0 X 30 greedy = 0 0 0 0 op = 30 0 0
Reidual Graph Original edge: e = (u, v) E. Flow (e), capaciy c(e). u 17 capaciy v low Reidual edge. "Undo" low en. e = (u, v) and e R = (v, u). reidual capaciy Reidual capaciy: u 11 v c(e) (e) i e E c (e) (e) i e R E reidual capaciy Reidual graph: G = (V, E ). Reidual edge wih poiive reidual capaciy. E = {e E : (e) < c(e)} {e R : e E and (e) > 0}. 3
Reidual graph (or Ford-Fulkeron) original graph wih low: 1 c (e) c(e) (e) i e E (e) i e R E 0 0 30 0 0 reidual graph: 1 0 0 0 0 0 0 0 0
Ford-Fulkeron lgorihm Ford-Fulkeron lgorihm. Sar wih (e) = 0 or all edge e E. Find an - pah P in reidual graph G where each edge ha (e) c(e). ugmen low along pah P. Repea unil you ge uck.
Ford-Fulkeron lgorihm G: capaciy 8 3 9 Q. How o ind an augmening pah?. Deph-ir earch or breadh-ir earch rom
Reidual graph Q. How can we ind he minimum cu (,B)? 1 0 0 0 7
Reidual graph Q. How can we ind he minimum cu (,B)?. Take = all node reachable in he reidual graph and B = he re. 1 0 0 0 8
ugmening Pah lgorihm ugmen(, c, P) { b boleneck(p,c) oreach e P { } i (e E) (e) (e) + b ele (e R ) (e R ) - b } reurn orward edge revere edge Ford-Fulkeron(G,,, c) { oreach e E (e) 0 G reidual graph (G) } while (here exi augmening pah P rom o ) { ugmen(, c, P) updae G } reurn Q. I hi algorihm correc? 9
Max-Flow Min-Cu Theorem ugmening pah heorem. Flow i a max low i here are no augmening pah. Max-low min-cu heorem. [Ford-Fulkeron 19] The value o he max low i equal o he capaciy o he min cu. Proo raegy. We prove boh imulaneouly by howing TFE: (i) There exi a cu (, B) uch ha v() = cap(, B). (ii) Flow i a max low. (iii) There i no augmening pah relaive o. he ollowing are equivalen (i) (ii) Q. Where did we ee hi one beore? 0
Max-Flow Min-Cu Theorem ugmening pah heorem. Flow i a max low i here are no augmening pah. Max-low min-cu heorem. [Ford-Fulkeron 19] The value o he max low i equal o he capaciy o he min cu. Proo raegy. We prove boh imulaneouly by howing TFE: (i) There exi a cu (, B) uch ha v() = cap(, B). (ii) Flow i a max low. (iii) There i no augmening pah relaive o. he ollowing are equivalen (i) (ii) Thi wa he corollary o he weak dualiy lemma. (ii) (iii) We how he conrapoiive, i.e. (iii) (ii) Le be a low. I here exi an augmening pah, hen we can improve by ending low along hi pah. Thu i no a max low. Q. Wha do we ill need o proo? 1
Proo o Max-Flow Min-Cu Theorem (iii) (i), i.e. i (iii) here i no augmening pah relaive o hen (i) a cu (, B) exi uch ha v() = cap(, B). P. Le be a low wih no augmening pah. Q. Which cu (,B) hould we ake o how ha v() = cap(, B)? B original nework
Proo o Max-Flow Min-Cu Theorem (iii) (i), i.e. i (iii) here i no augmening pah relaive o hen (i) a cu (, B) exi uch ha v() = cap(, B). P. Le be a low wih no augmening pah. Le be he e o verice reachable rom in reidual graph. (,B) i a cu, becaue and becaue no pah o in G,. Q. Wha do we know abou v() hen? B v( ) cap (, B ) original nework 3
Proo o Max-Flow Min-Cu Theorem (iii) (i), i.e. i (iii) here i no augmening pah relaive o hen (i) a cu (, B) exi uch ha v() = cap(, B). P. Le be a low wih no augmening pah. Le be he e o verice reachable rom in reidual graph. (,B) i a cu, becaue and becaue no pah o in G,. Q. Wha do we know abou ( e)? e ou o B low value lemma v( ) e ou o ( e) e in o ( e) original nework cap (, B )
Proo o Max-Flow Min-Cu Theorem (iii) (i), i.e. i (iii) here i no augmening pah relaive o hen (i) a cu (, B) exi uch ha v() = cap(, B). P. Le be a low wih no augmening pah. Le be he e o verice reachable rom in reidual graph. (,B) i a cu, becaue and becaue no pah o in G,. low (u,v) ou o i c(u,v), oherwie o v reachable in reidual graph e ou o ( e) e ou o c( e) B v( ) e ou o e ou o ( e) c( e) e in o... ( e) original nework cap (, B )
Proo o Max-Flow Min-Cu Theorem (iii) (i), i.e. i (iii) here i no augmening pah relaive o hen (i) a cu (, B) exi uch ha v() = cap(, B). P. Le be a low wih no augmening pah. Le be he e o verice reachable rom in reidual graph. (,B) i a cu, becaue and becaue no pah o in G,. low (u,v) ou o i c(u,v), oherwie o v reachable in reidual graph e ou o ( e) Q. Wha do we know abou ( e)? v( ) e ou o e ou o e ou o c( e) ( e) cap (, B ) e in o c( e)... e in o ( e) original nework B
Proo o Max-Flow Min-Cu Theorem (iii) (i), i.e. i (iii) here i no augmening pah relaive o hen (i) a cu (, B) exi uch ha v() = cap(, B). P. Le be a low wih no augmening pah. Le be he e o verice reachable rom in reidual graph. (,B) i a cu, becaue and becaue no pah o in G,. low (u,v) ou o i c(u,v), oherwie o v reachable in reidual graph e ou o ( e) e ou o c( e) B low (u,v) ino i zero, oherwie u reachable in reidual graph o v( ) e ou o e ou o ( e) c( e) 0 cap (, B ) e in o ( e) original nework Thi proo can be ound on page 38-39. 7
Max-Flow Min-Cu Theorem Proo (ummary). We have now hown ha: (i) (ii) (ii) (iii) (iii) (i) So, TFE: (he ollowing are equivalen) (i) There exi a cu (, B) uch ha v() = cap(, B). (ii) Flow i a max low. (iii) There i no augmening pah relaive o. ugmening pah heorem. Flow i a max low i here are no augmening pah. P. (ii) (iii) Max-low min-cu heorem. [Ford-Fulkeron 19] The value o he max low i equal o he capaciy o he min cu. P. (i) (ii), o cap(, B) = v() i max low. Corollary: (, B) i min cu. Thi proo can be ound on page 30. 8
ugmening Pah lgorihm ugmen(, c, P) { b boleneck(p,c) oreach e P { } i (e E) (e) (e) + b ele (e R ) (e) - b } reurn orward edge revere edge Ford-Fulkeron(G,,, c) { oreach e E (e) 0 G reidual graph (G) } while (here exi augmening pah P rom o ) { ugmen(, c, P) updae G } reurn Q. Wha i he run-ime complexiy o one ieraion o he while?
ugmening Pah lgorihm ugmen(, c, P) { b boleneck(p,c) oreach e P { } i (e E) (e) (e) + b ele (e R ) (e) - b } reurn orward edge revere edge Ford-Fulkeron(G,,, c) { oreach e E (e) 0 G reidual graph (G) } while (here exi augmening pah P rom o ) { ugmen(, c, P) updae G } reurn Q. Wha i he run-ime complexiy o one ieraion o he while?. O(m+n) or inding a pah, O(n) o augmen, o O(m) 0
Running Time Q. How many ieraion unil maximum low? Wha doe i depend upon?. The value o he maximum low, which depend on he capaciie. umpion. ll capaciie are ineger beween 1 and c*. Invarian. Every low value (e) and every reidual capaciy c (e) remain an ineger hroughou he algorihm. Inegraliy heorem. I all capaciie are ineger, hen here exi a max low or which every low value (e) i an ineger. P. Since algorihm erminae, heorem ollow rom invarian. Q. Wha i he value o he maximum poible low?. Maximum poible low i nc*, ince a mo n neighbor o. Q. Wha i he ime complexiy o Ford-Fulkeron? 1
Running Time Q. Wha i he ime complexiy o Ford-Fulkeron? Theorem. F-F erminae in a mo v(*) nc* ieraion, o O(mnc*). P. Maximum poible low i nc*, ince a mo n neighbor o. Each augmenaion increae value by a lea 1. O(m) per augmening pah. Q. Wha i he run ime i c* = 1?
Running Time Q. Wha i he ime complexiy o Ford-Fulkeron? Theorem. F-F erminae in a mo v(*) nc* ieraion, o O(mnc*). P. Maximum poible low i nc*, ince a mo n neighbor o. Each augmenaion increae value by a lea 1. O(m) per augmening pah. Corollary. I c* = 1, Ford-Fulkeron run in O(nm) ime. 3