Augmening Pah Algorihm Greedy-algorihm: ar wih f (e) = everywhere find an - pah wih f (e) < c(e) on every edge augmen flow along he pah repea a long a poible The Reidual Graph From he graph G = (V, E, c) and he curren flow f we conruc an auxiliary graph G f = (V, E f, c f ) (he reidual graph): Suppoe he original graph ha edge e = (u, v), and e = (v, u) beween u and v. G f ha edge e wih capaciy max{, c(e ) f (e ) + f (e )} and e wih wih capaciy max{, c(e ) f (e ) + f (e )}. G u v 3 G f u v Ern Mayr, Harald Räcke 3 Ern Mayr, Harald Räcke Augmening Pah Algorihm Augmening Pah Algorihm Definiion An augmening pah wih repec o flow f, i a pah from o in he auxiliary graph G f ha conain only edge wih non-zero capaciy. Algorihm FordFulkeron(G = (V, E, c)) : Iniialize f (e) for all edge. : while augmening pah p in G f do 3: augmen a much flow along p a poible. Animaion for augmening pah algorihm i only available in he lecure verion of he lide. Ern Mayr, Harald Räcke 5 Ern Mayr, Harald Räcke
Augmening Pah Algorihm Augmening Pah Algorihm Theorem A flow f i a maximum flow iff here are no augmening pah. Theorem 3 The value of a maximum flow i equal o he value of a minimum cu. Proof. Le f be a flow. The following are equivalen:. There exi a cu A, B uch ha val(f ) = cap(a, B).. Flow f i a maximum flow. 3. There i no augmening pah w.r.. f... Thi we already howed.. 3. If here were an augmening pah, we could improve he flow. Conradicion. 3.. Le f be a flow wih no augmening pah. Le A be he e of verice reachable from in he reidual graph along non-zero capaciy edge. Since here i no augmening pah we have A and A. Ern Mayr, Harald Räcke 7 Ern Mayr, Harald Räcke 8 Augmening Pah Algorihm Analyi val(f ) = f (e) f (e) e ou(a) = e ou(a) c(e) = cap(a, V \ A) Thi finihe he proof. e ino(a) Aumpion: All capaciie are ineger beween and C. Invarian: Every flow value f (e) and every reidual capaciy c f (e) remain inegral roughou he algorihm. Here he fir equaliy ue he flow value lemma, and he econd exploi he fac ha he flow along incoming edge mu be a he reidual graph doe no have edge leaving A. Ern Mayr, Harald Räcke 9 Ern Mayr, Harald Räcke
A Bad Inpu Lemma The algorihm erminae in a mo val(f ) nc ieraion, where f denoe he maximum flow. Each ieraion can be implemened in ime O(m). Thi give a oal running ime of O(nmC). Theorem 5 If all capaciie are ineger, hen here exi a maximum flow for which every flow value f (e) i inegral. Problem: The running ime may no be polynomial. Queion: Can we weak he algorihm o ha he running ime i polynomial in he inpu lengh? Ern Mayr, Harald Räcke Ern Mayr, Harald Räcke A Bad Inpu Problem: The running ime may no be polynomial. A Pahological Inpu Le r = ( 5 ). Then r n+ = r n r n+. r 5 3 r 3 Queion: Can we weak he algorihm o ha he running ime i polynomial in he inpu lengh? See he lecure-verion of he lide for he animaion. Running ime may be infinie!!! r + r 3 r 7 See he lecure-verion of he lide for he animaion. Ern Mayr, Harald Räcke 3 Ern Mayr, Harald Räcke
Overview: Shore Augmening Pah How o chooe augmening pah? We need o find pah efficienly. We wan o guaranee a mall number of ieraion. Several poibiliie: Chooe pah wih maximum boleneck capaciy. Chooe pah wih ufficienly large boleneck capaciy. Chooe he hore augmening pah. Lemma The lengh of he hore augmening pah never decreae. Lemma 7 Afer a mo O(m) augmenaion, he lengh of he hore augmening pah ricly increae. Ern Mayr, Harald Räcke 5. Shore Augmening Pah Ern Mayr, Harald Räcke Overview: Shore Augmening Pah Thee wo lemma give he following heorem: Theorem 8 The hore augmening pah algorihm perform a mo O(mn) augmenaion. Thi give a running ime of O(m n). Proof. We can find he hore augmening pah in ime O(m) via BFS. O(m) augmenaion for pah of exacly k < n edge. Shore Augmening Pah Define he level l(v) of a node a he lengh of he hore -v pah in G f. Le L G denoe he ubgraph of he reidual graph G f ha conain only hoe edge (u, v) wih l(v) = l(u) +. A pah P i a hore -u pah in G f if i i a an -u pah in L G. G f L G 3 9 5. Shore Augmening Pah Ern Mayr, Harald Räcke 7. Shore Augmening Pah Ern Mayr, Harald Räcke 8
Shore Augmening Pah Fir Lemma: The lengh of he hore augmening pah never decreae. In he following we aume ha he reidual graph G f doe no conain zero capaciy edge. Thi mean, we conruc i in he uual ene and hen delee edge of zero capaciy. Afer an augmenaion G f change a follow: Boleneck edge on he choen pah are deleed. Back edge are added o all edge ha don have back edge o far. Thee change canno decreae he diance beween and. G f L G 9 3 9 9 5 9. Shore Augmening Pah Ern Mayr, Harald Räcke 9 Shore Augmening Pah Second Lemma: Afer a mo m augmenaion he lengh of he hore augmening pah ricly increae. Le E L denoe he e of edge in graph L G a he beginning of a round when he diance beween and i k. An - pah in G f ha ue edge no in E L ha lengh larger han k, even when conidering edge added o G f during he round. In each augmenaion one edge i deleed from E L. G f E L 9 3 9 9 5 9 Shore Augmening Pah Theorem 9 The hore augmening pah algorihm perform a mo O(mn) augmenaion. Each augmenaion can be performed in ime O(m). Theorem (wihou proof) There exi nework wih m = Θ(n ) ha require O(mn) augmenaion, when we reric ourelve o only augmen along hore augmening pah. Noe: There alway exi a e of m augmenaion ha give a maximum flow (why?).. Shore Augmening Pah Ern Mayr, Harald Räcke
Shore Augmening Pah Shore Augmening Pah When icking o hore augmening pah we canno improve (aympoically) on he number of augmenaion. However, we can improve he running ime o O(mn ) by improving he running ime for finding an augmening pah (currenly we aume O(m) per augmenaion for hi). We mainain a ube E L of he edge of G f wih he guaranee ha a hore - pah uing only edge from E L i a hore augmening pah. Wih each augmenaion ome edge are deleed from E L. When E L doe no conain an - pah anymore he diance beween and ricly increae. Noe ha E L i no he e of edge of he level graph bu a ube of level-graph edge.. Shore Augmening Pah Ern Mayr, Harald Räcke 3. Shore Augmening Pah Ern Mayr, Harald Räcke Suppoe ha he iniial diance beween and in G f i k. E L i iniialized a he level graph L G. Perform a DFS earch o find a pah from o uing edge from E L. Eiher you find afer a mo n ep, or you end a a node v ha doe no have any ougoing edge. You can delee incoming edge of v from E L. Le a phae of he algorihm be defined by he ime beween wo augmenaion during which he diance beween and ricly increae. Iniializing E L for he phae ake ime O(m). The oal co for earching for augmening pah during a phae i a mo O(mn), ince every earch (ucceful (i.e., reaching ) or unucceful) decreae he number of edge in E L and ake ime O(n). The oal co for performing an augmenaion during a phae i only O(n). For every edge in he augmening pah one ha o updae he reidual graph G f and ha o check wheher he edge i ill in E L for he nex earch. There are a mo n phae. Hence, oal co i O(mn ).. Shore Augmening Pah Ern Mayr, Harald Räcke 5. Shore Augmening Pah Ern Mayr, Harald Räcke
How o chooe augmening pah? We need o find pah efficienly. We wan o guaranee a mall number of ieraion. Several poibiliie: Chooe pah wih maximum boleneck capaciy. Chooe pah wih ufficienly large boleneck capaciy. Chooe he hore augmening pah. Capaciy Scaling Inuiion: Chooing a pah wih he highe boleneck increae he flow a much a poible in a ingle ep. Don worry abou finding he exac boleneck. Mainain caling parameer. G f ( ) i a ub-graph of he reidual graph G f ha conain only edge wih capaciy a lea. G f G f (99) 5 33 87 5 33 Ern Mayr, Harald Räcke 7 Ern Mayr, Harald Räcke 8 Capaciy Scaling Algorihm maxflow(g,,, c) : foreach e E do f e ; : log C 3: while do : G f ( ) -reidual graph 5: while here i augmening pah P in G f ( ) do : f augmen(f, c, P) 7: updae(g f ( )) 8: / 9: reurn f Capaciy Scaling Aumpion: All capaciie are ineger beween and C. Invarian: All flow and capaciie are/remain inegral hroughou he algorihm. Correcne: The algorihm compue a maxflow: becaue of inegraliy we have G f () = G f herefore afer he la phae here are no augmening pah anymore hi mean we have a maximum flow. Ern Mayr, Harald Räcke 9 Ern Mayr, Harald Räcke 3
Capaciy Scaling Capaciy Scaling Lemma There are log C ieraion over. Proof: obviou. Lemma Le f be he flow a he end of a -phae. Then he maximum flow i maller han val(f ) + m. Proof: le obviou, bu imple: There mu exi an - cu in G f ( ) of zero capaciy. In G f hi cu can have capaciy a mo m. Thi give me an upper bound on he flow ha I can ill add. Lemma 3 There are a mo m augmenaion per caling-phae. Proof: Le f be he flow a he end of he previou phae. val(f ) val(f ) + m Each augmenaion increae flow by. Theorem We need O(m log C) augmenaion. The algorihm can be implemened in ime O(m log C). Ern Mayr, Harald Räcke 3 Ern Mayr, Harald Räcke 3