Nework flow The problem Seing flow nework G = (V, E, c), a orce and a ink no in E implie c(, ) = 0 Flow from o capaciy conrain kew-ymmery flow-coneraion ale of he flow jfj = P 2V Find a maximm flow from o c : V V! R + 0 [ f+g f : V V! R [ f+g 8 ;2V f(; ) c(; ) 8 ;2V f(; ) = f(; ) 8 2V f;g P2V f(; ): f(; ) = 0
Poiie flow Poiie flow f + (; ) = maxff(; ); 0g Flow coneraion X 8 2V f;g f + (; ) 2N + G () Vale of flow f jfj = X f + (; ) 2N + G () X X 2N G () f + (; ) = 0 2N G () f + (; ) Example capaciy poiie flow / / / / 30/ 30/ / / / / Flow from o wih ale aximm flow from o ha ale 30 2
Properie of flow Definiion of flow exended f(x; Y ) = X o e f(; ) 2X;2Y = X f + (; ) 2X;2Y 2X;2Y Properie of flow X f + (; ) 8 X½V f(x; X) = 0 8 X;Y ½V f(x; Y ) = f(y; X) 8 X;Y;Z½V X \ Y = ; ) f(x [ Y; Z) = f(x; Z) + f(y; Z) ^ f(z; X [ Y ) = f(z; X) + f(z; Y ) Flow coneraion 8 2V f;g f(; V ) = 0 Working wih he properie of flow jfj = f(; V ) = f(v; V ) f(v ; V ) = f(v ; V ) = f(v; V ) = f(v; ) + f(v; V ) = f(v; ) f(v ; V ) = f(v; ) he ale of he flow defined a he flow leaing he orce can eqialenly be regarded a he flow enering he ink 3
Flow decompoiion Gien wo flow f and g heir m f + g i defined a (f + g)(,) = f(,) + g(,) Propoiion: An - flow can be decompoed ino a mo m flow along pah from o, where m i he nmber of link in he nework Proof (kech): delee link wiho flow ake any link wih poiie flow recriely follow an ogoing link wih poiie flow oward ; recriely follow an incoming link wih poiie flow oward if a cycle i fond, find he poiie flow along he cycle and brac ha flow; a lea one link ha no flow and can be deleed ogeher wih i oppoie repea he proce nil a pah from o wih poiie flow i fond; find he poiie flow along ha pah and brac ha flow; one pah i fond and, afer bracion, a lea one link ha no flow and can be deleed ogeher wih i oppoie Flow decompoiion: example / / 30/ / / + +
Flow along pah / 30/ / 30-= Can injec a flow of ale along pah J diconing he flow along he pah preclde finding he maximm flow Phing flow back i imporan Reidal nework Gien nework G = (V,E,c) and a flow f from o, define he reidal capaciy from o c f (; ) = c(; ) f(; ) Gien nework G=(V,E,c) and a flow f from o, define he reidal nework indced by f on G, G f = (V, E f, c f ) E f = f(; ) 2 V V j c f (; ) > 0g If neiher nor belong o G, hen neiher nor belong o G f
Example / /0 30/ /0 / A nework and a flow Reidal nework indced by he flow Flow in reidal nework f i a flow in G=(V,E,c) G f i he reidal nework indced by f f i a flow in G f (f+f ) i a flow in G wih ale f+f = f + f Capaciy conrain (f + f 0 )(; ) = f(; ) + f 0 (; ) f(; ) + (c(; ) f(; )) = c(; ) Flow ale jf + f 0 j = X (f + f 0 )(; ) 2V = X 2V (f(; ) + f 0 (; )) = X f(; ) + X f 0 (; ) 2V 2V = jfj + jf 0 j 6
Agmening pah A pah P from o in reidal nework G f i an agmening pah Flow along agmening pah f P 8 < minfc f (; ) j 2 E(P )g if 2 E(P ) f P (; ) = minfc f (; ) j 2 E(P )g if 2 E(P ) : 0 oherwie Agmening pah P arae link if f p = c f (,) > 0 C and heir capaciie c (S, S) in a flow nework i a pariion of V ch ha S and S capaciy of (S, S) i c(s, S) jfj = f(; V ) = f(; V ) + f(s ; V ) = f(s; V ) = f(s; V ) f(s; S) = f(s; S) ¹ jfj = f(s; ¹ S) = X 2S;2 ¹S X 2S;2 ¹S = c(s; ¹ S); f(; ) c(; ) propoiion: eery flow ale i pper bonded by he capaciy of eery c
Example 30 aximm flow from o i a mo 0 aximm flow from o i a mo 30 ax-flow min-c heorem f i a maximm flow no agmening pah (,)-pah S = f j here i a pah in G f from o g: (S, S) i an (,)-c for eery S and S he reidal capaciy c f (,) = c(,) f(,) i zero h, c(s; S) ¹ = f(s; S) ¹ = jfj (S, S) i a minimm c; f i a maximm flow propoiion: he maximm ale of an (,)-flow eqal he minimm capaciy of an (,)-c 8
Ford-Flkeron mehod FordFlkeron(G) for each E do f[, ] = 0 f[, ] = 0 while here i a pah P from o in he reidal nework G f do r = min{ c(, ) f[, ] E(P)} for each E(P) do f[, ] = f[, ] + r f[, ] = - f[,] le C = c({}, V {}); if all capaciie are ineger, C i finie propoiion: if all capaciie are ineger, hen he Ford-Flkeron erminae in a mo C ieraion of he while loop; wor cae complexiy i O(mC) propoiion: if all capaciie are ineger, hen here i a maximm flow of inegral ale Ford-Flkeron: example I 6 2 9 3 6 2 9 6/ 2/ 9/ 3 3 / / 9
Ford-Flkeron: example II 2 8 6/ / 2/ 9/ / / 3 3 / / 8 3 3 2/2 6/ 9/ / / / 3 3 8 3/8 / / Ford-Flkeron: example III 3 8 2 3 2/2 6/ 9 / 3/2 / /9 / / 3 2 2 9 3 9 min c = 23 max flow = 23
Slow erminaion wih a bad choice of agmening pah i ake 2 of hem o find he maximm flow Non erminaion e 2 e 3 r Wih irraional capaciie, Ford- Flkeron may no erminae, and i may conerge o flow which i no he maximm flow e p r = 2 In he figre a he lef, an nfornae eqence of agmening pah may lead Ford- Flkeron mehod o neer erminae and conerge o a flow of ale + 2 / ( r), wherea he maximm flow i 2 +
Edmond-Karp algorihm chooe agmening pah which are of hore lengh in erm of nmber of link (BFS) Propoiion: le G f be a reidal nework and P an agmening pah from o. Then he diance from o a node in G f+fp i no maller han he diance from o he ame node in G f Proof: hypohei Conradicion. Chooe ch ha d Gf+fP (; ) < d Gf (; ) (diance from o i horer in G f+fp han in G f ) () d Gf+fP (; x) < d Gf+fP (; ) ) d Gf (; x) d Gf+fP (; x) (2) ( i he farhe node from in G f+fp ch ha diance from o i horer in G f+fp han in G f ) d Gf+fP (; ) + = d Gf+fP (; ) (3) ( i he paren of in hore pah from o in G f+fp ) 2
Proof: conradicion I Conradicion. Chooe ch ha d Gf+fP (; ) < d Gf (; ) d Gf+fP (; x) < d Gf+fP (; ) ) d Gf (; x) d Gf+fP (; x) d Gf+fP (; ) + = d Gf+fP (; ) () (2) (3) if i in E f G f G f+fp d Gf (; ) d Gf (; ) + d Gf+fP (; ) + = d Gf+fP (; ) ( i in E f ) (from (2)) (from (3)) Proof: conradicion II Conradicion. Chooe ch ha d Gf+fP (; ) < d Gf (; ) d Gf+fP (; x) < d Gf+fP (; ) ) d Gf (; x) d Gf+fP (; x) d Gf+fP (; ) + = d Gf+fP (; ) () (2) (3) if i no in E f, o ha i in an agmening pah in G f G f G f+fp d Gf (; ) = d Gf (; ) d Gf+fP (; ) = d Gf+fP (; ) 2 < d Gf+fP (; ) ( m be in he agmening pah) (from (2)) (from (3)) 3
Complexiy of Edmond-Karp Propoiion: he nmber of ime ha eiher link or link i araed i pper bonded by n Proof: agmening pah P arae in G f d Gf 0 (; ) = d Gf 0 (; ) + : agmening pah P arae in G f d Gf 00 (; ) = d Gf 00 (; ) + : araion of followed by araion of correpond o d Gf 0 (; ) + 2 d Gf 00 (; ) Nmber of agmening pah araing link i O(n) Nmber of agmening pah i O(n m) Oerall complexiy i O(n m 2 )