26.1 Flow networks. f (u,v) = 0.

Size: px
Start display at page:

Download "26.1 Flow networks. f (u,v) = 0."

Transcription

1 26 Maimum Flow Ju a we can model a road map a a direced graph in order o find he hore pah from one poin o anoher, we can alo inerpre a direced graph a a flow nework and ue i o anwer queion abou maerial flow. Imagine a maerial couring hrough a yem from a ource, where he maerial i produced, o a ink, where i i conumed. The ource produce he maerial a ome eady rae, and he ink conume he maerial a he ame rae. The flow of he maerial a any poin in he yem i inuiively he rae a which he maerial move. Flow nework can be ued o model liquid flowing hrough pipe, par hrough aembly line, curren hrough elecrical nework, informaion hrough communicaion nework, and o forh. Each direced edge in a flow nework can be hough of a a condui for he maerial. Each condui ha a aed capaciy, given a a maimum rae a which he maerial can flow hrough he condui, uch a 200 gallon of liquid per hour hrough a pipe or 20 ampere of elecrical curren hrough a wire. Verice are condui juncion, and oher han he ource and ink, maerial flow hrough he verice wihou collecing in hem. In oher word, he rae a which maerial ener a vere mu equal he rae a which i leave he vere. We call hi propery flow conervaion, and i i equivalen o Kirchhoff Curren Law when he maerial i elecrical curren. In he maimum-flow problem, we wih o compue he greae rae a which maerial can be hipped from he ource o he ink wihou violaing any capaciy conrain. I i one of he imple problem concerning flow nework and, a we hall ee in hi chaper, hi problem can be olved by efficien algorihm. Moreover, he baic echnique ued in maimum-flow algorihm can be adaped o olve oher nework-flow problem. Thi chaper preen wo general mehod for olving he maimum-flow problem. Secion 26.1 formalie he noion of flow nework and flow, formally defining he maimum-flow problem. Secion 26.2 decribe he claical mehod of Ford and Fulkeron for finding maimum flow. An applicaion of hi mehod, finding a maimum maching in an undireced biparie graph, i given in Sec-

2 6 Chaper 26 Maimum Flow ion Secion 26. preen he puh-relabel mehod, which underlie many of he fae algorihm for nework-flow problem. Secion 26. cover he relabelo-fron algorihm, a paricular implemenaion of he puh-relabel mehod ha run in ime O(V 3 ). Alhough hi algorihm i no he fae algorihm known, i illurae ome of he echnique ued in he aympoically fae algorihm, and i i reaonably efficien in pracice Flow nework In hi ecion, we give a graph-heoreic definiion of flow nework, dicu heir properie, and define he maimum-flow problem preciely. We alo inroduce ome helpful noaion. Flow nework and flow A flow nework G = (V, E) i a direced graph in which each edge (u,v) E ha a nonnegaive capaciy c(u,v) 0. If (u,v) E, we aume ha c(u,v) = 0. We diinguih wo verice in a flow nework: a ource and a ink. For convenience, we aume ha every vere lie on ome pah from he ource o he ink. Tha i, for every vere v V, here i a pah v. The graph i herefore conneced, and E V 1. Figure 26.1 how an eample of a flow nework. We are now ready o define flow more formally. Le G = (V, E) be a flow nework wih a capaciy funcion c. Le be he ource of he nework, and le be he ink. A flow in G i a real-valued funcion f : V V R ha aifie he following hree properie: Capaciy conrain: For all u, v V, we require f (u, v) c(u, v). Skew ymmery: For all u,v V, we require f (u,v) = f (v, u). Flow conervaion: For all u V {, }, we require f (u,v) = 0. v V The quaniy f (u,v), which can be poiive, ero, or negaive, i called he flow from vere u o vere v. The value of a flow f i defined a f = v V f (,v), (26.1) ha i, he oal flow ou of he ource. (Here, he noaion denoe flow value, no abolue value or cardinaliy.) In he maimum-flow problem, we are given a

3 26.1 Flow nework 6 Vancouver 16 Edmonon Sakaoon v 1 12 v 3 v 1 12/12 v 3 Winnipeg / / /9 7/7 1/ /13 v 2 1 v v 2 Calgary Regina (a) 11/1 (b) v / Figure 26.1 (a) A flow nework G = (V, E) for he Lucky Puck Company rucking problem. The Vancouver facory i he ource, and he Winnipeg warehoue i he ink. Puck are hipped hrough inermediae ciie, bu only c(u, v) crae per day can go from ciy u o ciy v. Each edge i labeled wih i capaciy. (b) A flow f in G wih value f = 19. Only poiive flow are hown. If f (u, v) > 0, edge (u, v) i labeled by f (u,v)/c(u, v). (The lah noaion i ued merely o eparae he flow and capaciy; i doe no indicae diviion.) If f (u, v) 0, edge (u, v) i labeled only by i capaciy. flow nework G wih ource and ink, and we wih o find a flow of maimum value. Before eeing an eample of a nework-flow problem, le u briefly eplore he hree flow properie. The capaciy conrain imply ay ha he flow from one vere o anoher mu no eceed he given capaciy. Skew ymmery i a noaional convenience ha ay ha he flow from a vere u o a vere v i he negaive of he flow in he revere direcion. The flow-conervaion propery ay ha he oal flow ou of a vere oher han he ource or ink i 0. By kew ymmery, we can rewrie he flow-conervaion propery a f (u,v) = 0 u V for all v V {, }. Tha i, he oal flow ino a vere i 0. When neiher (u,v) nor (v, u) i in E, here can be no flow beween u and v, and f (u,v) = f (v, u) = 0. (Eercie ak you o prove hi propery formally.) Our la obervaion concerning he flow properie deal wih flow ha are poiive. The oal poiive flow enering a vere v i defined by f (u,v). (26.2) u V f (u,v)>0 The oal poiive flow leaving a vere i defined ymmerically. We define he oal ne flow a a vere o be he oal poiive flow leaving a vere minu he oal poiive flow enering a vere. One inerpreaion of he flow-conervaion propery i ha he oal poiive flow enering a vere oher han he ource or

4 66 Chaper 26 Maimum Flow ink mu equal he oal poiive flow leaving ha vere. Thi propery, ha he oal ne flow a a vere mu equal 0, i ofen informally referred o a flow in equal flow ou. An eample of flow A flow nework can model he rucking problem hown in Figure 26.1(a). The Lucky Puck Company ha a facory (ource ) in Vancouver ha manufacure hockey puck, and i ha a warehoue (ink ) in Winnipeg ha ock hem. Lucky Puck leae pace on ruck from anoher firm o hip he puck from he facory o he warehoue. Becaue he ruck ravel over pecified roue (edge) beween ciie (verice) and have a limied capaciy, Lucky Puck can hip a mo c(u,v) crae per day beween each pair of ciie u and v in Figure 26.1(a). Lucky Puck ha no conrol over hee roue and capaciie and o canno aler he flow nework hown in Figure 26.1(a). Their goal i o deermine he large number p of crae per day ha can be hipped and hen o produce hi amoun, ince here i no poin in producing more puck han hey can hip o heir warehoue. Lucky Puck i no concerned wih how long i ake for a given puck o ge from he facory o he warehoue; hey care only ha p crae per day leave he facory and p crae per day arrive a he warehoue. On he urface, i eem appropriae o model he flow of hipmen wih a flow in hi nework becaue he number of crae hipped per day from one ciy o anoher i ubjec o a capaciy conrain. Addiionally, flow conervaion mu be obeyed, for in a eady ae, he rae a which puck ener an inermediae ciy mu equal he rae a which hey leave. Oherwie, crae would accumulae a inermediae ciie. There i one uble difference beween hipmen and flow, however. Lucky Puck may hip puck from Edmonon o Calgary, and hey may alo hip puck from Calgary o Edmonon. Suppoe ha hey hip 8 crae per day from Edmonon (v 1 in Figure 26.1) o Calgary (v 2 ) and 3 crae per day from Calgary o Edmonon. I may eem naural o repreen hee hipmen direcly by flow, bu we canno. The kew-ymmery conrain require ha f (v 1,v 2 ) = f (v 2,v 1 ), bu hi i clearly no he cae if we conider f (v 1,v 2 ) = 8 and f (v 2,v 1 ) = 3. Lucky Puck may realie ha i i poinle o hip 8 crae per day from Edmonon o Calgary and 3 crae from Calgary o Edmonon, when hey could achieve he ame ne effec by hipping crae from Edmonon o Calgary and 0 crae from Calgary o Edmonon (and preumably ue fewer reource in he proce). We repreen hi laer cenario wih a flow: we have f (v 1,v 2 ) = and f (v 2,v 1 ) =. In effec, 3 of he 8 crae per day from v 1 o v 2 are canceled by 3 crae per day from v 2 o v 1.

5 26.1 Flow nework 67 In general, cancellaion allow u o repreen he hipmen beween wo ciie by a flow ha i poiive along a mo one of he wo edge beween he correponding verice. Tha i, any iuaion in which puck are hipped in boh direcion beween wo ciie can be ranformed uing cancellaion ino an equivalen iuaion in which puck are hipped in one direcion only: he direcion of poiive flow. Given a flow f ha aroe from, ay, phyical hipmen, we canno reconruc he eac hipmen. If we know ha f (u,v) =, hi flow may be becaue uni were hipped from u o v, or i may be becaue 8 uni were hipped from u o v and 3 uni were hipped from v o u. Typically, we hall no care how he acual phyical hipmen are e up; for any pair of verice, we care only abou he ne amoun ha ravel beween hem. If we do care abou he underlying hipmen, hen we hould be uing a differen model, one ha reain informaion abou hipmen in boh direcion. Cancellaion will arie implicily in he algorihm in hi chaper. Suppoe ha edge (u,v) ha a flow value of f (u,v). In he coure of an algorihm, we may increae he flow on edge (v, u) by ome amoun d. Mahemaically, hi operaion mu decreae f (u,v) by d and, concepually, we can hink of hee d uni a canceling d uni of flow ha are already on edge (u,v). Nework wih muliple ource and ink A maimum-flow problem may have everal ource and ink, raher han ju one of each. The Lucky Puck Company, for eample, migh acually have a e of m facorie { 1, 2,..., m } and a e of n warehoue { 1, 2,..., n }, a hown in Figure 26.2(a). Forunaely, hi problem i no harder han ordinary maimum flow. We can reduce he problem of deermining a maimum flow in a nework wih muliple ource and muliple ink o an ordinary maimum-flow problem. Figure 26.2(b) how how he nework from (a) can be convered o an ordinary flow nework wih only a ingle ource and a ingle ink. We add a uperource and add a direced edge (, i ) wih capaciy c(, i ) = for each i = 1, 2,..., m. We alo creae a new uperink and add a direced edge ( i, ) wih capaciy c( i, ) = for each i = 1, 2,..., n. Inuiively, any flow in he nework in (a) correpond o a flow in he nework in (b), and vice vera. The ingle ource imply provide a much flow a deired for he muliple ource i, and he ingle ink likewie conume a much flow a deired for he muliple ink i. Eercie ak you o prove formally ha he wo problem are equivalen.

6 68 Chaper 26 Maimum Flow (a) (b) Figure 26.2 Convering a muliple-ource, muliple-ink maimum-flow problem ino a problem wih a ingle ource and a ingle ink. (a) A flow nework wih five ource S = { 1, 2, 3,, } and hree ink T = { 1, 2, 3 }. (b) An equivalen ingle-ource, ingle-ink flow nework. We add a uperource and an edge wih infinie capaciy from o each of he muliple ource. We alo add a uperink and an edge wih infinie capaciy from each of he muliple ink o. Working wih flow We hall be dealing wih everal funcion (like f ) ha ake a argumen wo verice in a flow nework. In hi chaper, we hall ue an implici ummaion noaion in which eiher argumen, or boh, may be a e of verice, wih he inerpreaion ha he value denoed i he um of all poible way of replacing he argumen wih heir member. For eample, if X and Y are e of verice, hen f (X, Y) = f (, y). X y Y Thu, he flow-conervaion conrain can be epreed a he condiion ha f (u, V) = 0 for all u V {, }. Alo, for convenience, we hall ypically omi e brace when hey would oherwie be ued in he implici ummaion noaion. For eample, in he equaion f (, V ) = f (, V), he erm V mean he e V {}.

7 26.1 Flow nework 69 The implici ummaion noaion ofen implifie equaion involving flow. The following lemma, whoe proof i lef a Eercie 26.1-, capure everal of he mo commonly occurring ideniie ha involve flow and he implici ummaion noaion. Lemma 26.1 Le G = (V, E) be a flow nework, and le f be a flow in G. Then he following equaliie hold: 1. For all X V, we have f (X, X) = For all X, Y V, we have f (X, Y) = f (Y, X). 3. For all X, Y, Z V wih X Y =, we have he um f (X Y, Z) = f (X, Z) + f (Y, Z) and f (Z, X Y) = f (Z, X) + f (Z, Y). A an eample of working wih he implici ummaion noaion, we can prove ha he value of a flow i he oal flow ino he ink; ha i, f = f (V, ). (26.3) Inuiively, we epec hi propery o hold. By flow conervaion, all verice oher han he ource and ink have equal amoun of oal poiive flow enering and leaving. The ource ha, by definiion, a oal ne flow ha i greaer han 0; ha i, more poiive flow leave he ource han ener i. Symmerically, he ink i he only vere ha can have a oal ne flow ha i le han 0; ha i, more poiive flow ener he ink han leave i. Our formal proof goe a follow: f = f (, V) (by definiion) = f (V, V) f (V, V) (by Lemma 26.1, par (3)) = f (V, V) (by Lemma 26.1, par (1)) = f (V, V ) (by Lemma 26.1, par (2)) = f (V, ) + f (V, V ) (by Lemma 26.1, par (3)) = f (V, ) (by flow conervaion). Laer in hi chaper, we hall generalie hi reul (Lemma 26.). Eercie Uing he definiion of a flow, prove ha if (u,v) E and (v, u) E hen f (u,v) = f (v, u) = Prove ha for any vere v oher han he ource or ink, he oal poiive flow enering v mu equal he oal poiive flow leaving v.

8 60 Chaper 26 Maimum Flow Eend he flow properie and definiion o he muliple-ource, muliple-ink problem. Show ha any flow in a muliple-ource, muliple-ink flow nework correpond o a flow of idenical value in he ingle-ource, ingle-ink nework obained by adding a uperource and a uperink, and vice vera Prove Lemma You hould no need o ue flow conervaion in your proof For he flow nework G = (V, E) and flow f hown in Figure 26.1(b), find a pair of ube X, Y V for which f (X, Y) = f (V X, Y). Then, find a pair of ube X, Y V for which f (X, Y) = f (V X, Y) Given a flow nework G = (V, E), le f 1 and f 2 be funcion from V V o R. The flow um f 1 + f 2 i he funcion from V V o R defined by ( f 1 + f 2 )(u,v) = f 1 (u,v) + f 2 (u,v) (26.) for all u,v V. If f 1 and f 2 are flow in G, which of he hree flow properie mu he flow um f 1 + f 2 aify, and which migh i violae? Le f be a flow in a nework, and le α be a real number. The calar flow produc, denoed α f, i a funcion from V V o R defined by (α f )(u,v) = α f (u,v). Prove ha he flow in a nework form a conve e. Tha i, how ha if f 1 and f 2 are flow, hen o i α f 1 + (1 α) f 2 for all α in he range 0 α Sae he maimum-flow problem a a linear-programming problem Profeor Adam ha wo children who, unforunaely, dilike each oher. The problem i o evere ha no only do hey refue o walk o chool ogeher, bu in fac each one refue o walk on any block ha he oher child ha epped on ha day. The children have no problem wih heir pah croing a a corner. Forunaely boh he profeor houe and he chool are on corner, bu beyond ha he i no ure if i i going o be poible o end boh of hi children o he ame chool. The profeor ha a map of hi own. Show how o formulae he problem of deermining if boh hi children can go o he ame chool a a maimum-flow problem.

9 26.2 The Ford-Fulkeron mehod The Ford-Fulkeron mehod Thi ecion preen he Ford-Fulkeron mehod for olving he maimum-flow problem. We call i a mehod raher han an algorihm becaue i encompae everal implemenaion wih differing running ime. The Ford-Fulkeron mehod depend on hree imporan idea ha rancend he mehod and are relevan o many flow algorihm and problem: reidual nework, augmening pah, and cu. Thee idea are eenial o he imporan ma-flow min-cu heorem (Theorem 26.7), which characerie he value of a maimum flow in erm of cu of he flow nework. We end hi ecion by preening one pecific implemenaion of he Ford-Fulkeron mehod and analying i running ime. The Ford-Fulkeron mehod i ieraive. We ar wih f (u,v) = 0 for all u,v V, giving an iniial flow of value 0. A each ieraion, we increae he flow value by finding an augmening pah, which we can hink of imply a a pah from he ource o he ink along which we can end more flow, and hen augmening he flow along hi pah. We repea hi proce unil no augmening pah can be found. The ma-flow min-cu heorem will how ha upon erminaion, hi proce yield a maimum flow. FORD-FULKERSON-METHOD(G,, ) 1 iniialie flow f o 0 2 while here ei an augmening pah p 3 do augmen flow f along p reurn f Reidual nework Inuiively, given a flow nework and a flow, he reidual nework coni of edge ha can admi more flow. More formally, uppoe ha we have a flow nework G = (V, E) wih ource and ink. Le f be a flow in G, and conider a pair of verice u,v V. The amoun of addiional flow we can puh from u o v before eceeding he capaciy c(u, v) i he reidual capaciy of (u, v), given by c f (u,v) = c(u,v) f (u,v). (26.) For eample, if c(u,v) = 16 and f (u,v) = 11, hen we can increae f (u,v) by c f (u,v) = uni before we eceed he capaciy conrain on edge (u,v). When he flow f (u,v) i negaive, he reidual capaciy c f (u,v) i greaer han he capaciy c(u,v). For eample, if c(u,v) = 16 and f (u,v) =, hen he reidual capaciy c f (u,v) i 20. We can inerpre hi iuaion a follow. There i a flow of uni from v o u, which we can cancel by puhing a flow of uni

10 62 Chaper 26 Maimum Flow 11/16 8/13 v / v 2 12/12 /9 11/1 (a) v 3 7/7 v 1/20 / v 1 v (b) v 3 7 v 1 11/16 12/13 v / v 2 12/ /1 (c) v 3 7/7 v 19/20 / v 1 v (d) v 3 7 v 19 1 Figure 26.3 (a) The flow nework G and flow f of Figure 26.1(b). (b) The reidual nework G f wih augmening pah p haded; i reidual capaciy i c f (p) = c f (v 2,v 3 ) =. (c) The flow in G ha reul from augmening along pah p by i reidual capaciy. (d) The reidual nework induced by he flow in (c). from u o v. We can hen puh anoher 16 uni from u o v before violaing he capaciy conrain on edge (u,v). We have hu puhed an addiional 20 uni of flow, aring wih a flow f (u, v) =, before reaching he capaciy conrain. Given a flow nework G = (V, E) and a flow f, he reidual nework of G induced by f i G f = (V, E f ), where E f = {(u,v) V V : c f (u,v) > 0}. Tha i, a promied above, each edge of he reidual nework, or reidual edge, can admi a flow ha i greaer han 0. Figure 26.3(a) repea he flow nework G and flow f of Figure 26.1(b), and Figure 26.3(b) how he correponding reidual nework G f. The edge in E f are eiher edge in E or heir reveral. If f (u,v) < c(u,v) for an edge (u,v) E, hen c f (u,v) = c(u,v) f (u,v) > 0 and (u,v) E f. If f (u,v) > 0 for an edge (u,v) E, hen f (v, u) < 0. In hi cae, c f (v, u) = c(v, u) f (v, u) > 0, and o (v, u) E f. If neiher (u,v) nor (v, u) appear in he original nework, hen c(u,v) = c(v, u) = 0, f (u,v) = f (v, u) = 0 (by Eercie ), and c f (u,v) = c f (v, u) = 0. We conclude ha an edge (u,v) can appear in a reidual nework only if a lea one of (u,v) and (v, u) appear in he original nework, and hu E f 2 E.

11 26.2 The Ford-Fulkeron mehod 63 Oberve ha he reidual nework G f i ielf a flow nework wih capaciie given by c f. The following lemma how how a flow in a reidual nework relae o a flow in he original flow nework. Lemma 26.2 Le G = (V, E) be a flow nework wih ource and ink, and le f be a flow in G. Le G f be he reidual nework of G induced by f, and le f be a flow in G f. Then he flow um f + f defined by equaion (26.) i a flow in G wih value f + f = f + f. Proof We mu verify ha kew ymmery, he capaciy conrain, and flow conervaion are obeyed. For kew ymmery, noe ha for all u,v V, we have ( 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). For he capaciy conrain, noe ha f (u,v) c f (u,v) for all u,v V. By equaion (26.), herefore, ( f + f )(u,v) = f (u,v) + f (u,v) f (u,v) + (c(u,v) f (u,v)) = c(u,v). For flow conervaion, noe ha for all u V {, }, we have f + f v V( )(u,v) = ( f (u,v) + f (u,v)) v V Finally, we have = f (u,v) + v V v V = = 0. f + f = v V( f + f )(,v) = v V( f (,v) + f (,v)) f (u,v) = v V f (,v) + v V f (,v) = f + f.

12 6 Chaper 26 Maimum Flow Augmening pah Given a flow nework G = (V, E) and a flow f, an augmening pah p i a imple pah from o in he reidual nework G f. By he definiion of he reidual nework, each edge (u, v) on an augmening pah admi ome addiional poiive flow from u o v wihou violaing he capaciy conrain on he edge. The haded pah in Figure 26.3(b) i an augmening pah. Treaing he reidual nework G f in he figure a a flow nework, we can increae he flow hrough each edge of hi pah by up o uni wihou violaing a capaciy conrain, ince he malle reidual capaciy on hi pah i c f (v 2,v 3 ) =. We call he maimum amoun by which we can increae he flow on each edge in an augmening pah p he reidual capaciy of p, given by c f (p) = min {c f (u,v) : (u,v) i on p}. The following lemma, whoe proof i lef a Eercie , make he above argumen more precie. Lemma 26.3 Le G = (V, E) be a flow nework, le f be a flow in G, and le p be an augmening pah in G f. Define a funcion f p : V V R by c f (p) if (u,v) i on p, f p (u,v) = c f (p) if (v, u) i on p, (26.6) 0 oherwie. Then, f p i a flow in G f wih value f p = c f (p) > 0. The following corollary how ha if we add f p o f, we ge anoher flow in G whoe value i cloer o he maimum. Figure 26.3(c) how he reul of adding f p in Figure 26.3(b) o f from Figure 26.3(a). Corollary 26. Le G = (V, E) be a flow nework, le f be a flow in G, and le p be an augmening pah in G f. Le f p be defined a in equaion (26.6). Define a funcion f : V V R by f = f + f p. Then f i a flow in G wih value f = f + f p > f. Proof Immediae from Lemma 26.2 and Cu of flow nework The Ford-Fulkeron mehod repeaedly augmen he flow along augmening pah unil a maimum flow ha been found. The ma-flow min-cu heorem, which

13 26.2 The Ford-Fulkeron mehod 6 11/16 10 v 1 1/ 12/12 /9 v 3 7/7 1/20 8/13 v 2 11/1 v / S T Figure 26. A cu (S, T) in he flow nework of Figure 26.1(b), where S = {,v 1,v 2 } and T = {v 3,v, }. The verice in S are black, and he verice in T are whie. The ne flow acro (S, T) i f (S, T) = 19, and he capaciy i c(s, T) = 26. we hall prove horly, ell u ha a flow i maimum if and only if i reidual nework conain no augmening pah. To prove hi heorem, hough, we mu fir eplore he noion of a cu of a flow nework. A cu (S, T) of flow nework G = (V, E) i a pariion of V ino S and T = V S uch ha S and T. (Thi definiion i imilar o he definiion of cu ha we ued for minimum panning ree in Chaper 23, ecep ha here we are cuing a direced graph raher han an undireced graph, and we ini ha S and T.) If f i a flow, hen he ne flow acro he cu (S, T) i defined o be f (S, T). The capaciy of he cu (S, T) i c(s, T). A minimum cu of a nework i a cu whoe capaciy i minimum over all cu of he nework. Figure 26. how he cu ({,v 1,v 2 },{v 3,v, }) in he flow nework of Figure 26.1(b). The ne flow acro hi cu i f (v 1,v 3 ) + f (v 2,v 3 ) + f (v 2,v ) = 12 + ( ) + 11 and i capaciy i c(v 1,v 3 ) + c(v 2,v ) = = 26. = 19, Oberve ha he ne flow acro a cu can include negaive flow beween verice, bu ha he capaciy of a cu i compoed enirely of nonnegaive value. In oher word, he ne flow acro a cu (S, T) coni of poiive flow in boh direcion; poiive flow from S o T i added while poiive flow from T o S i ubraced. On he oher hand, he capaciy of a cu (S, T) i compued only from edge going from S o T. Edge going from T o S are no included in he compuaion of c(s, T). The following lemma how ha he ne flow acro any cu i he ame, and i equal he value of he flow.

14 66 Chaper 26 Maimum Flow Lemma 26. Le f be a flow in a flow nework G wih ource and ink, and le (S, T) be a cu of G. Then he ne flow acro (S, T) i f (S, T) = f. Proof Noing ha f (S, V) = 0 by flow conervaion, we have f (S, T) = f (S, V) f (S, S) (by Lemma 26.1, par (3)) = f (S, V) (by Lemma 26.1, par (1)) = f (, V) + f (S, V) (by Lemma 26.1, par (3)) = f (, V) (ince f (S, V) = 0) = f. An immediae corollary o Lemma 26. i he reul we proved earlier equaion (26.3) ha he value of a flow i he oal flow ino he ink. Anoher corollary o Lemma 26. how how cu capaciie can be ued o bound he value of a flow. Corollary 26.6 The value of any flow f in a flow nework G i bounded from above by he capaciy of any cu of G. Proof Le (S, T) be any cu of G and le f be any flow. By Lemma 26. and he capaciy conrain, f = f (S, T) = f (u,v) u S v T c(u, v) u S v T = c(s, T). An immediae conequence of Corollary 26.6 i ha he maimum flow in a nework i bounded above by he capaciy of a minimum cu of he nework. The imporan ma-flow min-cu heorem, which we now ae and prove, ay ha he value of a maimum flow i in fac equal o he capaciy of a minimum cu.

15 26.2 The Ford-Fulkeron mehod 67 Theorem 26.7 (Ma-flow min-cu heorem) If f i a flow in a flow nework G = (V, E) wih ource and ink, hen he following condiion are equivalen: 1. f i a maimum flow in G. 2. The reidual nework G f conain no augmening pah. 3. f = c(s, T) for ome cu (S, T) of G. Proof (1) (2): Suppoe for he ake of conradicion ha f i a maimum flow in G bu ha G f ha an augmening pah p. Then, by Corollary 26., he flow um f + f p, where f p i given by equaion (26.6), i a flow in G wih value ricly greaer han f, conradicing he aumpion ha f i a maimum flow. (2) (3): Suppoe ha G f ha no augmening pah, ha i, ha G f conain no pah from o. Define S = {v V : here ei a pah from o v in G f } and T = V S. The pariion (S, T) i a cu: we have S rivially and S becaue here i no pah from o in G f. For each pair of verice u and v uch ha u S and v T, we have f (u,v) = c(u,v), ince oherwie (u,v) E f, which would place v in e S. By Lemma 26., herefore, f = f (S, T) = c(s, T). (3) (1): By Corollary 26.6, f c(s, T) for all cu (S, T). The condiion f = c(s, T) hu implie ha f i a maimum flow. The baic Ford-Fulkeron algorihm In each ieraion of he Ford-Fulkeron mehod, we find ome augmening pah p and increae he flow f on each edge of p by he reidual capaciy c f (p). The following implemenaion of he mehod compue he maimum flow in a graph G = (V, E) by updaing he flow f [u,v] beween each pair u,v of verice ha are conneced by an edge. 1 If u and v are no conneced by an edge in eiher direcion, we aume implicily ha f [u, v] = 0. The capaciie c(u, v) are aumed o be given along wih he graph, and c(u,v) = 0 if (u,v) E. The reidual capaciy c f (u,v) i compued in accordance wih he formula (26.). The epreion c f (p) in he code i acually ju a emporary variable ha ore he reidual capaciy of he pah p. 1 We ue quare bracke when we rea an idenifier uch a f a a muable field, and we ue parenhee when we rea i a a funcion.

16 68 Chaper 26 Maimum Flow FORD-FULKERSON(G,, ) 1 for each edge (u, v) E[G] 2 do f [u,v] 0 3 f [v, u] 0 while here ei a pah p from o in he reidual nework G f do c f (p) min {c f (u,v) : (u,v) i in p} 6 for each edge (u,v) in p 7 do f [u,v] f [u,v] + c f (p) 8 f [v, u] f [u,v] The FORD-FULKERSON algorihm imply epand on he FORD-FULKERSON- METHOD peudocode given earlier. Figure 26. how he reul of each ieraion in a ample run. Line 1 3 iniialie he flow f o 0. The while loop of line 8 repeaedly find an augmening pah p in G f and augmen flow f along p by he reidual capaciy c f (p). When no augmening pah ei, he flow f i a maimum flow. Analyi of Ford-Fulkeron The running ime of FORD-FULKERSON depend on how he augmening pah p in line i deermined. If i i choen poorly, he algorihm migh no even erminae: he value of he flow will increae wih ucceive augmenaion, bu i need no even converge o he maimum flow value. 2 If he augmening pah i choen by uing a breadh-fir earch (which we aw in Secion 22.2), however, he algorihm run in polynomial ime. Before proving hi reul, however, we obain a imple bound for he cae in which he augmening pah i choen arbirarily and all capaciie are ineger. Mo ofen in pracice, he maimum-flow problem arie wih inegral capaciie. If he capaciie are raional number, an appropriae caling ranformaion can be ued o make hem all inegral. Under hi aumpion, a raighforward implemenaion of FORD-FULKERSON run in ime O(E f ), where f i he maimum flow found by he algorihm. The analyi i a follow. Line 1 3 ake ime (E). The while loop of line 8 i eecued a mo f ime, ince he flow value increae by a lea one uni in each ieraion. The work done wihin he while loop can be made efficien if we efficienly manage he daa rucure ued o implemen he nework G = (V, E). Le u aume ha we keep a daa rucure correponding o a direced graph G = (V, E ), where E = {(u,v) : (u,v) E or (v, u) E}. Edge in he nework G are alo 2 The Ford-Fulkeron mehod migh fail o erminae only if edge capaciie are irraional number.

17 26.2 The Ford-Fulkeron mehod v 1 12 v 3 v 1 v 3 20 /16 /12 20 (a) / v 2 v v 2 v 1 /1 13 / (b) 12 v v /16 v 1 7/10 /12 /9 v 3 7/7 7/20 13 v 2 10 v 13 v 2 11/1 v / (c) 11 v v 3 v 1 v / / 12/12 /9 7/7 1/ /13 v 2 3 v v /1 v / (d) v 1 v v 12/12 3 v 3 7 v 1 11/16 12/13 v / v /1 7/7 v 19/20 / v 1 12 v 3 1 (e) v v 19 Figure 26. The eecuion of he baic Ford-Fulkeron algorihm. (a) (d) Succeive ieraion of he while loop. The lef ide of each par how he reidual nework G f from line wih a haded augmening pah p. The righ ide of each par how he new flow f ha reul from adding f p o f. The reidual nework in (a) i he inpu nework G. (e) The reidual nework a he la while loop e. I ha no augmening pah, and he flow f hown in (d) i herefore a maimum flow.

18 660 Chaper 26 Maimum Flow 1,000,000 1,000,000 u 1 v 1,000,000 1,000, , ,000,000 u 1 v 1,000, , , ,999 1 u 1 v 999, ,999 1 (a) (b) (c) Figure 26.6 (a) A flow nework for which FORD-FULKERSON can ake (E f ) ime, where f i a maimum flow, hown here wih f = 2,000,000. An augmening pah wih reidual capaciy 1 i hown. (b) The reuling reidual nework. Anoher augmening pah wih reidual capaciy 1 i hown. (c) The reuling reidual nework. edge in G, and i i herefore a imple maer o mainain capaciie and flow in hi daa rucure. Given a flow f on G, he edge in he reidual nework G f coni of all edge (u,v) of G uch ha c(u,v) f [u,v] = 0. The ime o find a pah in a reidual nework i herefore O(V + E ) = O(E) if we ue eiher deph-fir earch or breadh-fir earch. Each ieraion of he while loop hu ake O(E) ime, making he oal running ime of FORD-FULKERSON O(E f ). When he capaciie are inegral and he opimal flow value f i mall, he running ime of he Ford-Fulkeron algorihm i good. Figure 26.6(a) how an eample of wha can happen on a imple flow nework for which f i large. A maimum flow in hi nework ha value 2,000,000: 1,000,000 uni of flow ravere he pah u, and anoher 1,000,000 uni ravere he pah v. If he fir augmening pah found by FORD-FULKERSON i u v, hown in Figure 26.6(a), he flow ha value 1 afer he fir ieraion. The reuling reidual nework i hown in Figure 26.6(b). If he econd ieraion find he augmening pah v u, a hown in Figure 26.6(b), he flow hen ha value 2. Figure 26.6(c) how he reuling reidual nework. We can coninue, chooing he augmening pah u v in he odd-numbered ieraion and he augmening pah v u in he even-numbered ieraion. We would perform a oal of 2,000,000 augmenaion, increaing he flow value by only 1 uni in each. The Edmond-Karp algorihm The bound on FORD-FULKERSON can be improved if we implemen he compuaion of he augmening pah p in line wih a breadh-fir earch, ha i, if he augmening pah i a hore pah from o in he reidual nework, where each edge ha uni diance (weigh). We call he Ford-Fulkeron mehod o im-

19 26.2 The Ford-Fulkeron mehod 661 plemened he Edmond-Karp algorihm. We now prove ha he Edmond-Karp algorihm run in O(V E 2 ) ime. The analyi depend on he diance o verice in he reidual nework G f. The following lemma ue he noaion δ f (u,v) for he hore-pah diance from u o v in G f, where each edge ha uni diance. Lemma 26.8 If he Edmond-Karp algorihm i run on a flow nework G = (V, E) wih ource and ink, hen for all verice v V {, }, he hore-pah diance δ f (,v) in he reidual nework G f increae monoonically wih each flow augmenaion. Proof We will uppoe ha for ome vere v V {, }, here i a flow augmenaion ha caue he hore-pah diance from o v o decreae, and hen we will derive a conradicion. Le f be he flow ju before he fir augmenaion ha decreae ome hore-pah diance, and le f be he flow ju aferward. Le v be he vere wih he minimum δ f (,v) whoe diance wa decreaed by he augmenaion, o ha δ f (,v) < δ f (,v). Le p = u v be a hore pah from o v in G f, o ha (u,v) E f and δ f (, u) = δ f (,v) 1. (26.7) Becaue of how we choe v, we know ha he diance label of vere u did no decreae, i.e., δ f (, u) δ f (, u). (26.8) We claim ha (u,v) E f. Why? If we had (u,v) E f, hen we would alo have δ f (,v) δ f (, u) + 1 (by Lemma 2.10, he riangle inequaliy) δ f (, u) + 1 (by inequaliy (26.8)) = δ f (,v) (by equaion (26.7)), which conradic our aumpion ha δ f (,v) < δ f (,v). How can we have (u,v) E f and (u,v) E f? The augmenaion mu have increaed he flow from v o u. The Edmond-Karp algorihm alway augmen flow along hore pah, and herefore he hore pah from o u in G f ha (v, u) a i la edge. Therefore, δ f (,v) = δ f (, u) 1 δ f (, u) 1 (by inequaliy (26.8)) = δ f (,v) 2 (by equaion (26.7)), which conradic our aumpion ha δ f (,v) < δ f (,v). We conclude ha our aumpion ha uch a vere v ei i incorrec.

20 662 Chaper 26 Maimum Flow The ne heorem bound he number of ieraion of he Edmond-Karp algorihm. Theorem 26.9 If he Edmond-Karp algorihm i run on a flow nework G = (V, E) wih ource and ink, hen he oal number of flow augmenaion performed by he algorihm i O(V E). Proof We ay ha an edge (u,v) in a reidual nework G f i criical on an augmening pah p if he reidual capaciy of p i he reidual capaciy of (u,v), ha i, if c f (p) = c f (u,v). Afer we have augmened flow along an augmening pah, any criical edge on he pah diappear from he reidual nework. Moreover, a lea one edge on any augmening pah mu be criical. We will how ha each of he E edge can become criical a mo V /2 ime. Le u and v be verice in V ha are conneced by an edge in E. Since augmening pah are hore pah, when (u,v) i criical for he fir ime, we have δ f (,v) = δ f (, u) + 1. Once he flow i augmened, he edge (u,v) diappear from he reidual nework. I canno reappear laer on anoher augmening pah unil afer he flow from u o v i decreaed, which occur only if (v, u) appear on an augmening pah. If f i he flow in G when hi even occur, hen we have δ f (, u) = δ f (,v) + 1. Since δ f (,v) δ f (,v) by Lemma 26.8, we have δ f (, u) = δ f (,v) + 1 δ f (,v) + 1 = δ f (, u) + 2. Conequenly, from he ime (u,v) become criical o he ime when i ne become criical, he diance of u from he ource increae by a lea 2. The diance of u from he ource i iniially a lea 0. The inermediae verice on a hore pah from o u canno conain, u, or (ince (u,v) on he criical pah implie ha u = ). Therefore, unil u become unreachable from he ource, if ever, i diance i a mo V 2. Thu, afer he fir ime ha (u,v) become criical, i can become criical a mo ( V 2)/2 = V /2 1 ime more, for a oal of a mo V /2 ime. Since here are O(E) pair of verice ha can have an edge beween hem in a reidual graph, he oal number of criical edge during he enire eecuion of he Edmond-Karp algorihm i O(V E). Each augmening pah ha a lea one criical edge, and hence he heorem follow.

21 26.2 The Ford-Fulkeron mehod 663 Since each ieraion of FORD-FULKERSON can be implemened in O(E) ime when he augmening pah i found by breadh-fir earch, he oal running ime of he Edmond-Karp algorihm i O(V E 2 ). We hall ee ha puh-relabel algorihm can yield even beer bound. The algorihm of Secion 26. give a mehod for achieving an O(V 2 E) running ime, which form he bai for he O(V 3 )-ime algorihm of Secion 26.. Eercie In Figure 26.1(b), wha i he flow acro he cu ({,v 2,v },{v 1,v 3, })? Wha i he capaciy of hi cu? Show he eecuion of he Edmond-Karp algorihm on he flow nework of Figure 26.1(a) In he eample of Figure 26., wha i he minimum cu correponding o he maimum flow hown? Of he augmening pah appearing in he eample, which wo cancel flow? Prove ha for any pair of verice u and v and any capaciy and flow funcion c and f, we have c f (u,v) + c f (v, u) = c(u,v) + c(v, u) Recall ha he conrucion in Secion 26.1 ha conver a muliource, muliink flow nework ino a ingle-ource, ingle-ink nework add edge wih infinie capaciy. Prove ha any flow in he reuling nework ha a finie value if he edge of he original muliource, muliink nework have finie capaciy Suppoe ha each ource i in a muliource, muliink problem produce eacly p i uni of flow, o ha f ( i, V) = p i. Suppoe alo ha each ink j conume eacly q j uni, o ha f (V, j ) = q j, where i p i = j q j. Show how o conver he problem of finding a flow f ha obey hee addiional conrain ino he problem of finding a maimum flow in a ingle-ource, ingle-ink flow nework Prove Lemma 26.3.

22 66 Chaper 26 Maimum Flow Show ha a maimum flow in a nework G = (V, E) can alway be found by a equence of a mo E augmening pah. (Hin: Deermine he pah afer finding he maimum flow.) The edge conneciviy of an undireced graph i he minimum number k of edge ha mu be removed o diconnec he graph. For eample, he edge conneciviy of a ree i 1, and he edge conneciviy of a cyclic chain of verice i 2. Show how he edge conneciviy of an undireced graph G = (V, E) can be deermined by running a maimum-flow algorihm on a mo V flow nework, each having O(V) verice and O(E) edge Suppoe ha a flow nework G = (V, E) ha ymmeric edge, ha i, (u,v) E if and only if (v, u) E. Show ha he Edmond-Karp algorihm erminae afer a mo V E / ieraion. (Hin: For any edge (u, v), conider how boh δ(, u) and δ(v, ) change beween ime a which (u,v) i criical.) 26.3 Maimum biparie maching Some combinaorial problem can eaily be ca a maimum-flow problem. The muliple-ource, muliple-ink maimum-flow problem from Secion 26.1 gave u one eample. There are oher combinaorial problem ha eem on he urface o have lile o do wih flow nework, bu can in fac be reduced o maimum-flow problem. Thi ecion preen one uch problem: finding a maimum maching in a biparie graph (ee Secion B.). In order o olve hi problem, we hall ake advanage of an inegraliy propery provided by he Ford-Fulkeron mehod. We hall alo ee ha he Ford-Fulkeron mehod can be made o olve he maimumbiparie-maching problem on a graph G = (V, E) in O(V E) ime. The maimum-biparie-maching problem Given an undireced graph G = (V, E), a maching i a ube of edge M E uch ha for all verice v V, a mo one edge of M i inciden on v. We ay ha a vere v V i mached by maching M if ome edge in M i inciden on v; oherwie, v i unmached. A maimum maching i a maching of maimum cardinaliy, ha i, a maching M uch ha for any maching M, we have M M. In hi ecion, we hall reric our aenion o finding maimum maching in biparie graph. We aume ha he vere e can be pariioned ino V = L R,

23 26.3 Maimum biparie maching 66 L R L R (a) (b) Figure 26.7 A biparie graph G = (V, E) wih vere pariion V = L R. (a) A maching wih cardinaliy 2. (b) A maimum maching wih cardinaliy 3. where L and R are dijoin and all edge in E go beween L and R. We furher aume ha every vere in V ha a lea one inciden edge. Figure 26.7 illurae he noion of a maching. The problem of finding a maimum maching in a biparie graph ha many pracical applicaion. A an eample, we migh conider maching a e L of machine wih a e R of ak o be performed imulaneouly. We ake he preence of edge (u,v) in E o mean ha a paricular machine u L i capable of performing a paricular ak v R. A maimum maching provide work for a many machine a poible. Finding a maimum biparie maching We can ue he Ford-Fulkeron mehod o find a maimum maching in an undireced biparie graph G = (V, E) in ime polynomial in V and E. The rick i o conruc a flow nework in which flow correpond o maching, a hown in Figure We define he correponding flow nework G = (V, E ) for he biparie graph G a follow. We le he ource and ink be new verice no in V, and we le V = V {, }. If he vere pariion of G i V = L R, he direced edge of G are he edge of E, direced from L o R, along wih V new edge: E = {(, u) : u L} {(u,v) : u L, v R, and (u,v) E} {(v, ) : v R}.

24 666 Chaper 26 Maimum Flow L R L R (a) (b) Figure 26.8 The flow nework correponding o a biparie graph. (a) The biparie graph G = (V, E) wih vere pariion V = L R from Figure A maimum maching i hown by haded edge. (b) The correponding flow nework G wih a maimum flow hown. Each edge ha uni capaciy. Shaded edge have a flow of 1, and all oher edge carry no flow. The haded edge from L o R correpond o hoe in a maimum maching of he biparie graph. To complee he conrucion, we aign uni capaciy o each edge in E. Since each vere in V ha a lea one inciden edge, E V /2. Thu, E E = E + V 3 E, and o E = (E). The following lemma how ha a maching in G correpond direcly o a flow in G correponding flow nework G. We ay ha a flow f on a flow nework G = (V, E) i ineger-valued if f (u,v) i an ineger for all (u,v) V V. Lemma Le G = (V, E) be a biparie graph wih vere pariion V = L R, and le G = (V, E ) be i correponding flow nework. If M i a maching in G, hen here i an ineger-valued flow f in G wih value f = M. Converely, if f i an ineger-valued flow in G, hen here i a maching M in G wih cardinaliy M = f. Proof We fir how ha a maching M in G correpond o an ineger-valued flow f in G. Define f a follow. If (u,v) M, hen f (, u) = f (u,v) = f (v, ) = 1 and f (u, ) = f (v, u) = f (,v) = 1. For all oher edge (u,v) E, we define f (u,v) = 0. I i imple o verify ha f aifie kew ymmery, he capaciy conrain, and flow conervaion. Inuiively, each edge (u,v) M correpond o 1 uni of flow in G ha ravere he pah u v. Moreover, he pah induced by edge in M are

25 26.3 Maimum biparie maching 667 vere-dijoin, ecep for and. The ne flow acro cu (L {}, R {}) i equal o M ; hu, by Lemma 26., he value of he flow i f = M. To prove he convere, le f be an ineger-valued flow in G, and le M = {(u,v) : u L, v R, and f (u,v) > 0}. Each vere u L ha only one enering edge, namely (, u), and i capaciy i 1. Thu, each u L ha a mo one uni of poiive flow enering i, and if one uni of poiive flow doe ener, by flow conervaion, one uni of poiive flow mu leave. Furhermore, ince f i ineger-valued, for each u L, he one uni of flow can ener on a mo one edge and can leave on a mo one edge. Thu, one uni of poiive flow ener u if and only if here i eacly one vere v R uch ha f (u,v) = 1, and a mo one edge leaving each u L carrie poiive flow. A ymmeric argumen can be made for each v R. The e M i herefore a maching. To ee ha M = f, oberve ha for every mached vere u L, we have f (, u) = 1, and for every edge (u,v) E M, we have f (u,v) = 0. Conequenly, M = f (L, R) = f (L, V ) f (L, L) f (L, ) f (L, ) (by Lemma 26.1). We can implify he above epreion coniderably. Flow conervaion implie ha f (L, V ) = 0; Lemma 26.1 implie ha f (L, L) = 0; kew ymmery implie ha f (L, ) = f (, L); and becaue here are no edge from L o, we have f (L, ) = 0. Thu, M = f (, L) = f (, V ) (ince all edge ou of go o L) = f (by he definiion of f ). Baed on Lemma 26.10, we would like o conclude ha a maimum maching in a biparie graph G correpond o a maimum flow in i correponding flow nework G, and we can herefore compue a maimum maching in G by running a maimum-flow algorihm on G. The only hich in hi reaoning i ha he maimum-flow algorihm migh reurn a flow in G for which ome f (u,v) i no an ineger, even hough he flow value f mu be an ineger. The following heorem how ha if we ue he Ford-Fulkeron mehod, hi difficuly canno arie. Theorem (Inegraliy heorem) If he capaciy funcion c ake on only inegral value, hen he maimum flow f produced by he Ford-Fulkeron mehod ha he propery ha f i ineger-valued. Moreover, for all verice u and v, he value of f (u,v) i an ineger.

26 668 Chaper 26 Maimum Flow Proof The proof i by inducion on he number of ieraion. We leave i a Eercie We can now prove he following corollary o Lemma Corollary The cardinaliy of a maimum maching M in a biparie graph G equal he value of a maimum flow f in i correponding flow nework G. Proof We ue he nomenclaure from Lemma Suppoe ha M i a maimum maching in G and ha he correponding flow f in G i no maimum. Then here i a maimum flow f in G uch ha f > f. Since he capaciie in G are ineger-valued, by Theorem 26.11, we can aume ha f i ineger-valued. Thu, f correpond o a maching M in G wih cardinaliy M = f > f = M, conradicing our aumpion ha M i a maimum maching. In a imilar manner, we can how ha if f i a maimum flow in G, i correponding maching i a maimum maching on G. Thu, given a biparie undireced graph G, we can find a maimum maching by creaing he flow nework G, running he Ford-Fulkeron mehod, and direcly obaining a maimum maching M from he ineger-valued maimum flow f found. Since any maching in a biparie graph ha cardinaliy a mo min(l, R) = O(V), he value of he maimum flow in G i O(V). We can herefore find a maimum maching in a biparie graph in ime O(V E ) = O(V E), ince E = (E). Eercie Run he Ford-Fulkeron algorihm on he flow nework in Figure 26.8(b) and how he reidual nework afer each flow augmenaion. Number he verice in L op o boom from 1 o and in R op o boom from 6 o 9. For each ieraion, pick he augmening pah ha i leicographically malle Prove Theorem Le G = (V, E) be a biparie graph wih vere pariion V = L R, and le G be i correponding flow nework. Give a good upper bound on he lengh of any augmening pah found in G during he eecuion of FORD-FULKERSON.

27 26. Puh-relabel algorihm A perfec maching i a maching in which every vere i mached. Le G = (V, E) be an undireced biparie graph wih vere pariion V = L R, where L = R. For any X V, define he neighborhood of X a N(X) = {y V : (, y) E for ome X}, ha i, he e of verice adjacen o ome member of X. Prove Hall heorem: here ei a perfec maching in G if and only if A N(A) for every ube A L We ay ha a biparie graph G = (V, E), where V = L R, i d-regular if every vere v V ha degree eacly d. Every d-regular biparie graph ha L = R. Prove ha every d-regular biparie graph ha a maching of cardinaliy L by arguing ha a minimum cu of he correponding flow nework ha capaciy L. 26. Puh-relabel algorihm In hi ecion, we preen he puh-relabel approach o compuing maimum flow. To dae, many of he aympoically fae maimum-flow algorihm are puh-relabel algorihm, and he fae acual implemenaion of maimum-flow algorihm are baed on he puh-relabel mehod. Oher flow problem, uch a he minimum-co flow problem, can be olved efficienly by puh-relabel mehod. Thi ecion inroduce Goldberg generic maimum-flow algorihm, which ha a imple implemenaion ha run in O(V 2 E) ime, hereby improving upon he O(V E 2 ) bound of he Edmond-Karp algorihm. Secion 26. refine he generic algorihm o obain anoher puh-relabel algorihm ha run in O(V 3 ) ime. Puh-relabel algorihm work in a more localied manner han he Ford- Fulkeron mehod. Raher han eamine he enire reidual nework o find an augmening pah, puh-relabel algorihm work on one vere a a ime, looking only a he vere neighbor in he reidual nework. Furhermore, unlike he Ford- Fulkeron mehod, puh-relabel algorihm do no mainain he flow-conervaion propery hroughou heir eecuion. They do, however, mainain a preflow, which i a funcion f : V V R ha aifie kew ymmery, capaciy conrain, and he following relaaion of flow conervaion: f (V, u) 0 for all verice u V {}. We call hi quaniy he ece flow ino vere u, given by e(u) = f (V, u). (26.9) We ay ha a vere u V {, } i overflowing if e(u) > 0.

28 670 Chaper 26 Maimum Flow We hall ar hi ecion by decribing he inuiion behind he puh-relabel mehod. We hall hen inveigae he wo operaion employed by he mehod: puhing preflow and relabeling a vere. Finally, we hall preen a generic puh-relabel algorihm and analye i correcne and running ime. Inuiion The inuiion behind he puh-relabel mehod i probably be underood in erm of fluid flow: we conider a flow nework G = (V, E) o be a yem of inerconneced pipe of given capaciie. Applying hi analogy o he Ford-Fulkeron mehod, we migh ay ha each augmening pah in he nework give rie o an addiional ream of fluid, wih no branch poin, flowing from he ource o he ink. The Ford-Fulkeron mehod ieraively add more ream of flow unil no more can be added. The generic puh-relabel algorihm ha a raher differen inuiion. A before, direced edge correpond o pipe. Verice, which are pipe juncion, have wo inereing properie. Fir, o accommodae ece flow, each vere ha an ouflow pipe leading o an arbirarily large reervoir ha can accumulae fluid. Second, each vere, i reervoir, and all i pipe connecion are on a plaform whoe heigh increae a he algorihm progree. Vere heigh deermine how flow i puhed: we only puh flow downhill, ha i, from a higher vere o a lower vere. The flow from a lower vere o a higher vere may be poiive, bu operaion ha puh flow only puh i downhill. The heigh of he ource i fied a V, and he heigh of he ink i fied a 0. All oher vere heigh ar a 0 and increae wih ime. The algorihm fir end a much flow a poible downhill from he ource oward he ink. The amoun i end i eacly enough o fill each ougoing pipe from he ource o capaciy; ha i, i end he capaciy of he cu (, V ). When flow fir ener an inermediae vere, i collec in he vere reervoir. From here, i i evenually puhed downhill. I may evenually happen ha he only pipe ha leave a vere u and are no already auraed wih flow connec o verice ha are on he ame level a u or are uphill from u. In hi cae, o rid an overflowing vere u of i ece flow, we mu increae i heigh an operaion called relabeling vere u. I heigh i increaed o one uni more han he heigh of he lowe of i neighbor o which i ha an unauraed pipe. Afer a vere i relabeled, herefore, here i a lea one ougoing pipe hrough which more flow can be puhed. Evenually, all he flow ha can poibly ge hrough o he ink ha arrived here. No more can arrive, becaue he pipe obey he capaciy conrain; he amoun of flow acro any cu i ill limied by he capaciy of he cu. To make he preflow a legal flow, he algorihm hen end he ece colleced in he reervoir of

29 26. Puh-relabel algorihm 671 overflowing verice back o he ource by coninuing o relabel verice o above he fied heigh V of he ource. A we hall ee, once all he reervoir have been empied, he preflow i no only a legal flow, i i alo a maimum flow. The baic operaion From he preceding dicuion, we ee ha here are wo baic operaion performed by a puh-relabel algorihm: puhing flow ece from a vere o one of i neighbor and relabeling a vere. The applicabiliy of hee operaion depend on he heigh of verice, which we now define preciely. Le G = (V, E) be a flow nework wih ource and ink, and le f be a preflow in G. A funcion h : V N i a heigh funcion 3 if h() = V, h() = 0, and h(u) h(v) + 1 for every reidual edge (u,v) E f. We immediaely obain he following lemma. Lemma Le G = (V, E) be a flow nework, le f be a preflow in G, and le h be a heigh funcion on V. For any wo verice u,v V, if h(u) > h(v) + 1, hen (u,v) i no an edge in he reidual graph. The puh operaion The baic operaion PUSH(u,v) can be applied if u i an overflowing vere, c f (u,v) > 0, and h(u) = h(v) + 1. The peudocode below updae he preflow f in an implied nework G = (V, E). I aume ha reidual capaciie can alo be compued in conan ime given c and f. The ece flow ored a a vere u i mainained a he aribue e[u], and he heigh of u i mainained a he aribue h[u]. The epreion d f (u,v) i a emporary variable ha ore he amoun of flow ha can be puhed from u o v. 3 In he lieraure, a heigh funcion i ypically called a diance funcion, and he heigh of a vere i called a diance label. We ue he erm heigh becaue i i more uggeive of he inuiion behind he algorihm. We reain he ue of he erm relabel o refer o he operaion ha increae he heigh of a vere. The heigh of a vere i relaed o i diance from he ink, a would be found in a breadh-fir earch of he ranpoe G T.

1 Motivation and Basic Definitions

1 Motivation and Basic Definitions CSCE : Deign and Analyi of Algorihm Noe on Max Flow Fall 20 (Baed on he preenaion in Chaper 26 of Inroducion o Algorihm, 3rd Ed. by Cormen, Leieron, Rive and Sein.) Moivaion and Baic Definiion Conider

More information

Flow networks, flow, maximum flow. Some definitions. Edmonton. Saskatoon Winnipeg. Vancouver Regina. Calgary. 12/12 a.

Flow networks, flow, maximum flow. Some definitions. Edmonton. Saskatoon Winnipeg. Vancouver Regina. Calgary. 12/12 a. Flow nework, flow, maximum flow Can inerpre direced graph a flow nework. Maerial coure hrough ome yem from ome ource o ome ink. Source produce maerial a ome eady rae, ink conume a ame rae. Example: waer

More information

Flow networks. Flow Networks. A flow on a network. Flow networks. The maximum-flow problem. Introduction to Algorithms, Lecture 22 December 5, 2001

Flow networks. Flow Networks. A flow on a network. Flow networks. The maximum-flow problem. Introduction to Algorithms, Lecture 22 December 5, 2001 CS 545 Flow Nework lon Efra Slide courey of Charle Leieron wih mall change by Carola Wenk Flow nework Definiion. flow nework i a direced graph G = (V, E) wih wo diinguihed verice: a ource and a ink. Each

More information

Main Reference: Sections in CLRS.

Main Reference: Sections in CLRS. Maximum Flow Reied 09/09/200 Main Reference: Secion 26.-26. in CLRS. Inroducion Definiion Muli-Source Muli-Sink The Ford-Fulkeron Mehod Reidual Nework Augmening Pah The Max-Flow Min-Cu Theorem The Edmond-Karp

More information

Graphs III - Network Flow

Graphs III - Network Flow Graph III - Nework Flow Flow nework eup graph G=(V,E) edge capaciy w(u,v) 0 - if edge doe no exi, hen w(u,v)=0 pecial verice: ource verex ; ink verex - no edge ino and no edge ou of Aume every verex v

More information

Problem Set If all directed edges in a network have distinct capacities, then there is a unique maximum flow.

Problem Set If all directed edges in a network have distinct capacities, then there is a unique maximum flow. CSE 202: Deign and Analyi of Algorihm Winer 2013 Problem Se 3 Inrucor: Kamalika Chaudhuri Due on: Tue. Feb 26, 2013 Inrucion For your proof, you may ue any lower bound, algorihm or daa rucure from he ex

More information

CS 473G Lecture 15: Max-Flow Algorithms and Applications Fall 2005

CS 473G Lecture 15: Max-Flow Algorithms and Applications Fall 2005 CS 473G Lecure 1: Max-Flow Algorihm and Applicaion Fall 200 1 Max-Flow Algorihm and Applicaion (November 1) 1.1 Recap Fix a direced graph G = (V, E) ha doe no conain boh an edge u v and i reveral v u,

More information

Algorithms and Data Structures 2011/12 Week 9 Solutions (Tues 15th - Fri 18th Nov)

Algorithms and Data Structures 2011/12 Week 9 Solutions (Tues 15th - Fri 18th Nov) Algorihm and Daa Srucure 2011/ Week Soluion (Tue 15h - Fri 18h No) 1. Queion: e are gien 11/16 / 15/20 8/13 0/ 1/ / 11/1 / / To queion: (a) Find a pair of ube X, Y V uch ha f(x, Y) = f(v X, Y). (b) Find

More information

Randomized Perfect Bipartite Matching

Randomized Perfect Bipartite Matching Inenive Algorihm Lecure 24 Randomized Perfec Biparie Maching Lecurer: Daniel A. Spielman April 9, 208 24. Inroducion We explain a randomized algorihm by Ahih Goel, Michael Kapralov and Sanjeev Khanna for

More information

CSC 364S Notes University of Toronto, Spring, The networks we will consider are directed graphs, where each edge has associated with it

CSC 364S Notes University of Toronto, Spring, The networks we will consider are directed graphs, where each edge has associated with it CSC 36S Noe Univeriy of Torono, Spring, 2003 Flow Algorihm The nework we will conider are direced graph, where each edge ha aociaed wih i a nonnegaive capaciy. The inuiion i ha if edge (u; v) ha capaciy

More information

Network Flows: Introduction & Maximum Flow

Network Flows: Introduction & Maximum Flow CSC 373 - lgorihm Deign, nalyi, and Complexiy Summer 2016 Lalla Mouaadid Nework Flow: Inroducion & Maximum Flow We now urn our aenion o anoher powerful algorihmic echnique: Local Search. In a local earch

More information

The Residual Graph. 12 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

The Residual Graph. 12 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm 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,

More information

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1 Conider he following flow nework CS444/944 Analyi of Algorihm II Soluion for Aignmen (0 mark) In he following nework a minimum cu ha capaciy 0 Eiher prove ha hi aemen i rue, or how ha i i fale Uing he

More information

16 Max-Flow Algorithms and Applications

16 Max-Flow Algorithms and Applications Algorihm A proce canno be underood by opping i. Underanding mu move wih he flow of he proce, mu join i and flow wih i. The Fir Law of Mena, in Frank Herber Dune (196) There a difference beween knowing

More information

The Residual Graph. 11 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

The Residual Graph. 11 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm 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,

More information

Today: Max Flow Proofs

Today: Max Flow Proofs Today: Max Flow Proof COSC 58, Algorihm March 4, 04 Many of hee lide are adaped from everal online ource Reading Aignmen Today cla: Chaper 6 Reading aignmen for nex cla: Chaper 7 (Amorized analyi) In-Cla

More information

Matching. Slides designed by Kevin Wayne.

Matching. Slides designed by Kevin Wayne. Maching Maching. Inpu: undireced graph G = (V, E). M E i a maching if each node appear in a mo edge in M. Max maching: find a max cardinaliy maching. Slide deigned by Kevin Wayne. Biparie Maching Biparie

More information

Algorithmic Discrete Mathematics 6. Exercise Sheet

Algorithmic Discrete Mathematics 6. Exercise Sheet Algorihmic Dicree Mahemaic. Exercie Shee Deparmen of Mahemaic SS 0 PD Dr. Ulf Lorenz 7. and 8. Juni 0 Dipl.-Mah. David Meffer Verion of June, 0 Groupwork Exercie G (Heap-Sor) Ue Heap-Sor wih a min-heap

More information

Soviet Rail Network, 1955

Soviet Rail Network, 1955 Sovie Rail Nework, 1 Reference: On he hiory of he ranporaion and maximum flow problem. Alexander Schrijver in Mah Programming, 1: 3,. Maximum Flow and Minimum Cu Max flow and min cu. Two very rich algorihmic

More information

18 Extensions of Maximum Flow

18 Extensions of Maximum Flow Who are you?" aid Lunkwill, riing angrily from hi ea. Wha do you wan?" I am Majikhie!" announced he older one. And I demand ha I am Vroomfondel!" houed he younger one. Majikhie urned on Vroomfondel. I

More information

Admin MAX FLOW APPLICATIONS. Flow graph/networks. Flow constraints 4/30/13. CS lunch today Grading. in-flow = out-flow for every vertex (except s, t)

Admin MAX FLOW APPLICATIONS. Flow graph/networks. Flow constraints 4/30/13. CS lunch today Grading. in-flow = out-flow for every vertex (except s, t) /0/ dmin lunch oday rading MX LOW PPLIION 0, pring avid Kauchak low graph/nework low nework direced, weighed graph (V, ) poiive edge weigh indicaing he capaciy (generally, aume ineger) conain a ingle ource

More information

Maximum Flow and Minimum Cut

Maximum Flow and Minimum Cut // Sovie Rail Nework, Maximum Flow and Minimum Cu Max flow and min cu. Two very rich algorihmic problem. Cornerone problem in combinaorial opimizaion. Beauiful mahemaical dualiy. Nework Flow Flow nework.

More information

CSE 521: Design & Analysis of Algorithms I

CSE 521: Design & Analysis of Algorithms I CSE 52: Deign & Analyi of Algorihm I Nework Flow Paul Beame Biparie Maching Given: A biparie graph G=(V,E) M E i a maching in G iff no wo edge in M hare a verex Goal: Find a maching M in G of maximum poible

More information

Soviet Rail Network, 1955

Soviet Rail Network, 1955 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

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorihm Deign and Analyi LECTURE 0 Nework Flow Applicaion Biparie maching Edge-dijoin pah Adam Smih 0//0 A. Smih; baed on lide by E. Demaine, C. Leieron, S. Rakhodnikova, K. Wayne La ime: Ford-Fulkeron

More information

Network Flow. Data Structures and Algorithms Andrei Bulatov

Network Flow. Data Structures and Algorithms Andrei Bulatov Nework Flow Daa Srucure and Algorihm Andrei Bulao Algorihm Nework Flow 24-2 Flow Nework Think of a graph a yem of pipe We ue hi yem o pump waer from he ource o ink Eery pipe/edge ha limied capaciy Flow

More information

! Abstraction for material flowing through the edges. ! G = (V, E) = directed graph, no parallel edges.

! Abstraction for material flowing through the edges. ! G = (V, E) = directed graph, no parallel edges. Sovie Rail Nework, haper Nework Flow Slide by Kevin Wayne. opyrigh Pearon-ddion Weley. ll righ reerved. Reference: On he hiory of he ranporaion and maximum flow problem. lexander Schrijver in Mah Programming,

More information

Max Flow, Min Cut COS 521. Kevin Wayne Fall Soviet Rail Network, Cuts. Minimum Cut Problem. Flow network.

Max Flow, Min Cut COS 521. Kevin Wayne Fall Soviet Rail Network, Cuts. Minimum Cut Problem. Flow network. Sovie Rail Nework, Max Flow, Min u OS Kevin Wayne Fall Reference: On he hiory of he ranporaion and maximum flow problem. lexander Schrijver in Mah Programming, :,. Minimum u Problem u Flow nework.! Digraph

More information

Introduction to Congestion Games

Introduction to Congestion Games Algorihmic Game Theory, Summer 2017 Inroducion o Congeion Game Lecure 1 (5 page) Inrucor: Thoma Keelheim In hi lecure, we ge o know congeion game, which will be our running example for many concep in game

More information

Network Flows UPCOPENCOURSEWARE number 34414

Network Flows UPCOPENCOURSEWARE number 34414 Nework Flow UPCOPENCOURSEWARE number Topic : F.-Javier Heredia Thi work i licened under he Creaive Common Aribuion- NonCommercial-NoDeriv. Unpored Licene. To view a copy of hi licene, vii hp://creaivecommon.org/licene/by-nc-nd/./

More information

4/12/12. Applications of the Maxflow Problem 7.5 Bipartite Matching. Bipartite Matching. Bipartite Matching. Bipartite matching: the flow network

4/12/12. Applications of the Maxflow Problem 7.5 Bipartite Matching. Bipartite Matching. Bipartite Matching. Bipartite matching: the flow network // Applicaion of he Maxflow Problem. Biparie Maching Biparie Maching Biparie maching. Inpu: undireced, biparie graph = (, E). M E i a maching if each node appear in a mo one edge in M. Max maching: find

More information

MAXIMUM FLOW. introduction Ford-Fulkerson algorithm maxflow-mincut theorem

MAXIMUM FLOW. introduction Ford-Fulkerson algorithm maxflow-mincut theorem MAXIMUM FLOW inroducion Ford-Fulkeron algorihm maxflow-mincu heorem Mincu problem Inpu. An edge-weighed digraph, ource verex, and arge verex. each edge ha a poiive capaciy capaciy 9 10 4 15 15 10 5 8 10

More information

Greedy. I Divide and Conquer. I Dynamic Programming. I Network Flows. Network Flow. I Previous topics: design techniques

Greedy. I Divide and Conquer. I Dynamic Programming. I Network Flows. Network Flow. I Previous topics: design techniques Algorihm Deign Technique CS : Nework Flow Dan Sheldon April, reedy Divide and Conquer Dynamic Programming Nework Flow Comparion Nework Flow Previou opic: deign echnique reedy Divide and Conquer Dynamic

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorihm Deign and Analyi LECTURES 17 Nework Flow Dualiy of Max Flow and Min Cu Algorihm: Ford-Fulkeron Capaciy Scaling Sofya Rakhodnikova S. Rakhodnikova; baed on lide by E. Demaine, C. Leieron, A. Smih,

More information

They were originally developed for network problem [Dantzig, Ford, Fulkerson 1956]

They were originally developed for network problem [Dantzig, Ford, Fulkerson 1956] 6. Inroducion... 6. The primal-dual algorihmn... 6 6. Remark on he primal-dual algorihmn... 7 6. A primal-dual algorihmn for he hore pah problem... 8... 9 6.6 A primal-dual algorihmn for he weighed maching

More information

Flow Networks. Ma/CS 6a. Class 14: Flow Exercises

Flow Networks. Ma/CS 6a. Class 14: Flow Exercises 0/0/206 Ma/CS 6a Cla 4: Flow Exercie Flow Nework A flow nework i a digraph G = V, E, ogeher wih a ource verex V, a ink verex V, and a capaciy funcion c: E N. Capaciy Source 7 a b c d e Sink 0/0/206 Flow

More information

Maximum Flow. How do we transport the maximum amount data from source to sink? Some of these slides are adapted from Lecture Notes of Kevin Wayne.

Maximum Flow. How do we transport the maximum amount data from source to sink? Some of these slides are adapted from Lecture Notes of Kevin Wayne. Conen Conen. Maximum flow problem. Minimum cu problem. Max-flow min-cu heorem. Augmening pah algorihm. Capaciy-caling. Shore augmening pah. Chaper Maximum How do we ranpor he maximum amoun daa from ource

More information

6/3/2009. CS 244 Algorithm Design Instructor: t Artur Czumaj. Lecture 8 Network flows. Maximum Flow and Minimum Cut. Minimum Cut Problem.

6/3/2009. CS 244 Algorithm Design Instructor: t Artur Czumaj. Lecture 8 Network flows. Maximum Flow and Minimum Cut. Minimum Cut Problem. Maximum Flow and Minimum Cu CS lgorihm Deign Inrucor: rur Czumaj Lecure Nework Max and min cu. Two very rich algorihmic problem. Cornerone problem in combinaorial opimizaion. Beauiful mahemaical dualiy.

More information

Reminder: Flow Networks

Reminder: Flow Networks 0/0/204 Ma/CS 6a Cla 4: Variou (Flow) Execie Reminder: Flow Nework A flow nework i a digraph G = V, E, ogeher wih a ource verex V, a ink verex V, and a capaciy funcion c: E N. Capaciy Source 7 a b c d

More information

, the. L and the L. x x. max. i n. It is easy to show that these two norms satisfy the following relation: x x n x = (17.3) max

, the. L and the L. x x. max. i n. It is easy to show that these two norms satisfy the following relation: x x n x = (17.3) max ecure 8 7. Sabiliy Analyi For an n dimenional vecor R n, he and he vecor norm are defined a: = T = i n i (7.) I i eay o how ha hee wo norm aify he following relaion: n (7.) If a vecor i ime-dependen, hen

More information

CHAPTER 7: SECOND-ORDER CIRCUITS

CHAPTER 7: SECOND-ORDER CIRCUITS EEE5: CI RCUI T THEORY CHAPTER 7: SECOND-ORDER CIRCUITS 7. Inroducion Thi chaper conider circui wih wo orage elemen. Known a econd-order circui becaue heir repone are decribed by differenial equaion ha

More information

Chapter 7: Inverse-Response Systems

Chapter 7: Inverse-Response Systems Chaper 7: Invere-Repone Syem Normal Syem Invere-Repone Syem Baic Sar ou in he wrong direcion End up in he original eady-ae gain value Two or more yem wih differen magniude and cale in parallel Main yem

More information

Please Complete Course Survey. CMPSCI 311: Introduction to Algorithms. Approximation Algorithms. Coping With NP-Completeness. Greedy Vertex Cover

Please Complete Course Survey. CMPSCI 311: Introduction to Algorithms. Approximation Algorithms. Coping With NP-Completeness. Greedy Vertex Cover Pleae Complee Coure Survey CMPSCI : Inroducion o Algorihm Dealing wih NP-Compleene Dan Sheldon hp: //owl.oi.uma.edu/parner/coureevalsurvey/uma/ Univeriy of Maachue Slide Adaped from Kevin Wayne La Compiled:

More information

Introduction to SLE Lecture Notes

Introduction to SLE Lecture Notes Inroducion o SLE Lecure Noe May 13, 16 - The goal of hi ecion i o find a ufficien condiion of λ for he hull K o be generaed by a imple cure. I urn ou if λ 1 < 4 hen K i generaed by a imple curve. We will

More information

Average Case Lower Bounds for Monotone Switching Networks

Average Case Lower Bounds for Monotone Switching Networks Average Cae Lower Bound for Monoone Swiching Nework Yuval Filmu, Toniann Piai, Rober Robere, Sephen Cook Deparmen of Compuer Science Univeriy of Torono Monoone Compuaion (Refreher) Monoone circui were

More information

EECE 301 Signals & Systems Prof. Mark Fowler

EECE 301 Signals & Systems Prof. Mark Fowler EECE 31 Signal & Syem Prof. Mark Fowler Noe Se #27 C-T Syem: Laplace Tranform Power Tool for yem analyi Reading Aignmen: Secion 6.1 6.3 of Kamen and Heck 1/18 Coure Flow Diagram The arrow here how concepual

More information

CSE 421 Introduction to Algorithms Winter The Network Flow Problem

CSE 421 Introduction to Algorithms Winter The Network Flow Problem CSE 42 Inroducion o Algorihm Winer 202 The Nework Flow Problem 2 The Nework Flow Problem 5 a 4 3 x 3 7 6 b 4 y 4 7 6 c 5 z How much uff can flow from o? 3 Sovie Rail Nework, 955 Reference: On he hiory

More information

Basic Tools CMSC 641. Running Time. Problem. Problem. Algorithmic Design Paradigms. lg (n!) (lg n)! (lg n) lgn n.2

Basic Tools CMSC 641. Running Time. Problem. Problem. Algorithmic Design Paradigms. lg (n!) (lg n)! (lg n) lgn n.2 Baic Tool CMSC April, Review Aympoic Noaion Order of Growh Recurrence relaion Daa Srucure Li, Heap, Graph, Tree, Balanced Tree, Hah Table Advanced daa rucure: Binomial Heap, Fibonacci Heap Soring Mehod

More information

23 Maximum Flows and Minimum Cuts

23 Maximum Flows and Minimum Cuts A proce canno be underood by opping i. Underanding mu move wih he flow of he proce, mu join i and flow wih i. The Fir Law of Mena, in Frank Herber Dune (196) Conrary o expecaion, flow uually happen no

More information

6.8 Laplace Transform: General Formulas

6.8 Laplace Transform: General Formulas 48 HAP. 6 Laplace Tranform 6.8 Laplace Tranform: General Formula Formula Name, ommen Sec. F() l{ f ()} e f () d f () l {F()} Definiion of Tranform Invere Tranform 6. l{af () bg()} al{f ()} bl{g()} Lineariy

More information

To become more mathematically correct, Circuit equations are Algebraic Differential equations. from KVL, KCL from the constitutive relationship

To become more mathematically correct, Circuit equations are Algebraic Differential equations. from KVL, KCL from the constitutive relationship Laplace Tranform (Lin & DeCarlo: Ch 3) ENSC30 Elecric Circui II The Laplace ranform i an inegral ranformaion. I ranform: f ( ) F( ) ime variable complex variable From Euler > Lagrange > Laplace. Hence,

More information

Discussion Session 2 Constant Acceleration/Relative Motion Week 03

Discussion Session 2 Constant Acceleration/Relative Motion Week 03 PHYS 100 Dicuion Seion Conan Acceleraion/Relaive Moion Week 03 The Plan Today you will work wih your group explore he idea of reference frame (i.e. relaive moion) and moion wih conan acceleraion. You ll

More information

Maximum Flow. Contents. Max Flow Network. Maximum Flow and Minimum Cut

Maximum Flow. Contents. Max Flow Network. Maximum Flow and Minimum Cut Conen Maximum Flow Conen. Maximum low problem. Minimum cu problem. Max-low min-cu heorem. Augmening pah algorihm. Capaciy-caling. Shore augmening pah. Princeon Univeriy COS Theory o Algorihm Spring Kevin

More information

u(t) Figure 1. Open loop control system

u(t) Figure 1. Open loop control system Open loop conrol v cloed loop feedbac conrol The nex wo figure preen he rucure of open loop and feedbac conrol yem Figure how an open loop conrol yem whoe funcion i o caue he oupu y o follow he reference

More information

2. VECTORS. R Vectors are denoted by bold-face characters such as R, V, etc. The magnitude of a vector, such as R, is denoted as R, R, V

2. VECTORS. R Vectors are denoted by bold-face characters such as R, V, etc. The magnitude of a vector, such as R, is denoted as R, R, V ME 352 VETS 2. VETS Vecor algebra form he mahemaical foundaion for kinemaic and dnamic. Geomer of moion i a he hear of boh he kinemaic and dnamic of mechanical em. Vecor anali i he imehonored ool for decribing

More information

Math 2142 Exam 1 Review Problems. x 2 + f (0) 3! for the 3rd Taylor polynomial at x = 0. To calculate the various quantities:

Math 2142 Exam 1 Review Problems. x 2 + f (0) 3! for the 3rd Taylor polynomial at x = 0. To calculate the various quantities: Mah 4 Eam Review Problems Problem. Calculae he 3rd Taylor polynomial for arcsin a =. Soluion. Le f() = arcsin. For his problem, we use he formula f() + f () + f ()! + f () 3! for he 3rd Taylor polynomial

More information

18.03SC Unit 3 Practice Exam and Solutions

18.03SC Unit 3 Practice Exam and Solutions Sudy Guide on Sep, Dela, Convoluion, Laplace You can hink of he ep funcion u() a any nice mooh funcion which i for < a and for > a, where a i a poiive number which i much maller han any ime cale we care

More information

Today s topics. CSE 421 Algorithms. Problem Reduction Examples. Problem Reduction. Undirected Network Flow. Bipartite Matching. Problem Reductions

Today s topics. CSE 421 Algorithms. Problem Reduction Examples. Problem Reduction. Undirected Network Flow. Bipartite Matching. Problem Reductions Today opic CSE Algorihm Richard Anderon Lecure Nework Flow Applicaion Prolem Reducion Undireced Flow o Flow Biparie Maching Dijoin Pah Prolem Circulaion Loweround conrain on flow Survey deign Prolem Reducion

More information

CHAPTER 12 DIRECT CURRENT CIRCUITS

CHAPTER 12 DIRECT CURRENT CIRCUITS CHAPTER 12 DIRECT CURRENT CIUITS DIRECT CURRENT CIUITS 257 12.1 RESISTORS IN SERIES AND IN PARALLEL When wo resisors are conneced ogeher as shown in Figure 12.1 we said ha hey are conneced in series. As

More information

Physics 240: Worksheet 16 Name

Physics 240: Worksheet 16 Name Phyic 4: Workhee 16 Nae Non-unifor circular oion Each of hee proble involve non-unifor circular oion wih a conan α. (1) Obain each of he equaion of oion for non-unifor circular oion under a conan acceleraion,

More information

13.1 Accelerating Objects

13.1 Accelerating Objects 13.1 Acceleraing Objec A you learned in Chaper 12, when you are ravelling a a conan peed in a raigh line, you have uniform moion. However, mo objec do no ravel a conan peed in a raigh line o hey do no

More information

CMPS 6610/4610 Fall Flow Networks. Carola Wenk Slides adapted from slides by Charles Leiserson

CMPS 6610/4610 Fall Flow Networks. Carola Wenk Slides adapted from slides by Charles Leiserson CMP 6610/4610 Fall 2016 Flow Nework Carola Wenk lide adaped rom lide by Charle Leieron Max low and min c Fndamenal problem in combinaorial opimizaion Daliy beween max low and min c Many applicaion: Biparie

More information

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Algorithms. Algorithms 6.4 MAXIMUM FLOW Algorihm ROBERT SEDGEWICK KEVIN WAYNE 6.4 MAXIMUM FLOW Algorihm F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE hp://alg4.c.princeon.edu inroducion Ford Fulkeron algorihm maxflow mincu heorem analyi

More information

16 Max-Flow Algorithms

16 Max-Flow Algorithms A process canno be undersood by sopping i. Undersanding mus move wih he flow of he process, mus join i and flow wih i. The Firs Law of Mena, in Frank Herber s Dune (196) There s a difference beween knowing

More information

Notes on cointegration of real interest rates and real exchange rates. ρ (2)

Notes on cointegration of real interest rates and real exchange rates. ρ (2) Noe on coinegraion of real inere rae and real exchange rae Charle ngel, Univeriy of Wiconin Le me ar wih he obervaion ha while he lieraure (mo prominenly Meee and Rogoff (988) and dion and Paul (993))

More information

April 3, The maximum flow problem. See class notes on website.

April 3, The maximum flow problem. See class notes on website. 5.05 April, 007 The maximum flow problem See cla noe on webie. Quoe of he day You ge he maxx for he minimum a TJ Maxx. -- ad for a clohing ore Thi wa he mo unkinde cu of all -- Shakepeare in Juliu Caear

More information

Vehicle Arrival Models : Headway

Vehicle Arrival Models : Headway Chaper 12 Vehicle Arrival Models : Headway 12.1 Inroducion Modelling arrival of vehicle a secion of road is an imporan sep in raffic flow modelling. I has imporan applicaion in raffic flow simulaion where

More information

KINEMATICS IN ONE DIMENSION

KINEMATICS IN ONE DIMENSION KINEMATICS IN ONE DIMENSION PREVIEW Kinemaics is he sudy of how hings move how far (disance and displacemen), how fas (speed and velociy), and how fas ha how fas changes (acceleraion). We say ha an objec

More information

Maximum Flow in Planar Graphs

Maximum Flow in Planar Graphs Maximum Flow in Planar Graph Planar Graph and i Dual Dualiy i defined for direced planar graph a well Minimum - cu in undireced planar graph An - cu (undireced graph) An - cu The dual o he cu Cu/Cycle

More information

arxiv: v1 [cs.cg] 21 Mar 2013

arxiv: v1 [cs.cg] 21 Mar 2013 On he rech facor of he Thea-4 graph Lui Barba Proenji Boe Jean-Lou De Carufel André van Renen Sander Verdoncho arxiv:1303.5473v1 [c.cg] 21 Mar 2013 Abrac In hi paper we how ha he θ-graph wih 4 cone ha

More information

Wrap up: Weighted, directed graph shortest path Minimum Spanning Tree. Feb 25, 2019 CSCI211 - Sprenkle

Wrap up: Weighted, directed graph shortest path Minimum Spanning Tree. Feb 25, 2019 CSCI211 - Sprenkle Objecive Wrap up: Weighed, direced graph hore pah Minimum Spanning Tree eb, 1 SI - Sprenkle 1 Review Wha are greedy algorihm? Wha i our emplae for olving hem? Review he la problem we were working on: Single-ource,

More information

KEY. Math 334 Midterm I Fall 2008 sections 001 and 003 Instructor: Scott Glasgow

KEY. Math 334 Midterm I Fall 2008 sections 001 and 003 Instructor: Scott Glasgow 1 KEY Mah 4 Miderm I Fall 8 secions 1 and Insrucor: Sco Glasgow Please do NOT wrie on his eam. No credi will be given for such work. Raher wrie in a blue book, or on our own paper, preferabl engineering

More information

3/3/2015. Chapter 7. Network Flow. Maximum Flow and Minimum Cut. Minimum Cut Problem

3/3/2015. Chapter 7. Network Flow. Maximum Flow and Minimum Cut. Minimum Cut Problem // Chaper Nework Flow Maximum Flow and Minimum Cu Max flow and min cu. Two very rich algorihmic problem. Cornerone problem in combinaorial opimizaion. Beauiful mahemaical dualiy. Nonrivial applicaion /

More information

13.1 Circuit Elements in the s Domain Circuit Analysis in the s Domain The Transfer Function and Natural Response 13.

13.1 Circuit Elements in the s Domain Circuit Analysis in the s Domain The Transfer Function and Natural Response 13. Chaper 3 The Laplace Tranform in Circui Analyi 3. Circui Elemen in he Domain 3.-3 Circui Analyi in he Domain 3.4-5 The Tranfer Funcion and Naural Repone 3.6 The Tranfer Funcion and he Convoluion Inegral

More information

ARTIFICIAL INTELLIGENCE. Markov decision processes

ARTIFICIAL INTELLIGENCE. Markov decision processes INFOB2KI 2017-2018 Urech Univeriy The Neherland ARTIFICIAL INTELLIGENCE Markov deciion procee Lecurer: Silja Renooij Thee lide are par of he INFOB2KI Coure Noe available from www.c.uu.nl/doc/vakken/b2ki/chema.hml

More information

5.1 - Logarithms and Their Properties

5.1 - Logarithms and Their Properties Chaper 5 Logarihmic Funcions 5.1 - Logarihms and Their Properies Suppose ha a populaion grows according o he formula P 10, where P is he colony size a ime, in hours. When will he populaion be 2500? We

More information

NECESSARY AND SUFFICIENT CONDITIONS FOR LATENT SEPARABILITY

NECESSARY AND SUFFICIENT CONDITIONS FOR LATENT SEPARABILITY NECESSARY AND SUFFICIENT CONDITIONS FOR LATENT SEPARABILITY Ian Crawford THE INSTITUTE FOR FISCAL STUDIES DEPARTMENT OF ECONOMICS, UCL cemmap working paper CWP02/04 Neceary and Sufficien Condiion for Laen

More information

The Arcsine Distribution

The Arcsine Distribution The Arcsine Disribuion Chris H. Rycrof Ocober 6, 006 A common heme of he class has been ha he saisics of single walker are ofen very differen from hose of an ensemble of walkers. On he firs homework, we

More information

SMT 2014 Calculus Test Solutions February 15, 2014 = 3 5 = 15.

SMT 2014 Calculus Test Solutions February 15, 2014 = 3 5 = 15. SMT Calculus Tes Soluions February 5,. Le f() = and le g() =. Compue f ()g (). Answer: 5 Soluion: We noe ha f () = and g () = 6. Then f ()g () =. Plugging in = we ge f ()g () = 6 = 3 5 = 5.. There is a

More information

FLAT CYCLOTOMIC POLYNOMIALS OF ORDER FOUR AND HIGHER

FLAT CYCLOTOMIC POLYNOMIALS OF ORDER FOUR AND HIGHER #A30 INTEGERS 10 (010), 357-363 FLAT CYCLOTOMIC POLYNOMIALS OF ORDER FOUR AND HIGHER Nahan Kaplan Deparmen of Mahemaic, Harvard Univeriy, Cambridge, MA nkaplan@mah.harvard.edu Received: 7/15/09, Revied:

More information

Linear Algebra Primer

Linear Algebra Primer Linear Algebra rimer And a video dicuion of linear algebra from EE263 i here (lecure 3 and 4): hp://ee.anford.edu/coure/ee263 lide from Sanford CS3 Ouline Vecor and marice Baic Mari Operaion Deerminan,

More information

How to Solve System Dynamic s Problems

How to Solve System Dynamic s Problems How o Solve Sye Dynaic Proble A ye dynaic proble involve wo or ore bodie (objec) under he influence of everal exernal force. The objec ay uliaely re, ove wih conan velociy, conan acceleraion or oe cobinaion

More information

EE202 Circuit Theory II

EE202 Circuit Theory II EE202 Circui Theory II 2017-2018, Spring Dr. Yılmaz KALKAN I. Inroducion & eview of Fir Order Circui (Chaper 7 of Nilon - 3 Hr. Inroducion, C and L Circui, Naural and Sep epone of Serie and Parallel L/C

More information

EE Control Systems LECTURE 2

EE Control Systems LECTURE 2 Copyrigh F.L. Lewi 999 All righ reerved EE 434 - Conrol Syem LECTURE REVIEW OF LAPLACE TRANSFORM LAPLACE TRANSFORM The Laplace ranform i very ueful in analyi and deign for yem ha are linear and ime-invarian

More information

Network flows. The problem. c : V V! R + 0 [ f+1g. flow network G = (V, E, c), a source s and a sink t uv not in E implies c(u, v) = 0

Network flows. The problem. c : V V! R + 0 [ f+1g. flow network G = (V, E, c), a source s and a sink t uv not in E implies c(u, v) = 0 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

More information

Graph Theory: Network Flow

Graph Theory: Network Flow Univeriy of Wahingon Mah 336 Term Paper Graph Theory: Nework Flow Auhor: Ellio Broard Advier: Dr. Jame Morrow 3 June 200 Conen Inroducion...................................... 2 2 Terminology......................................

More information

Linear Motion, Speed & Velocity

Linear Motion, Speed & Velocity Add Iporan Linear Moion, Speed & Velociy Page: 136 Linear Moion, Speed & Velociy NGSS Sandard: N/A MA Curriculu Fraework (2006): 1.1, 1.2 AP Phyic 1 Learning Objecive: 3.A.1.1, 3.A.1.3 Knowledge/Underanding

More information

Selfish Routing. Tim Roughgarden Cornell University. Includes joint work with Éva Tardos

Selfish Routing. Tim Roughgarden Cornell University. Includes joint work with Éva Tardos Selfih Rouing Tim Roughgarden Cornell Univeriy Include join work wih Éva Tardo 1 Which roue would you chooe? Example: one uni of raffic (e.g., car) wan o go from o delay = 1 hour (no congeion effec) long

More information

T L. t=1. Proof of Lemma 1. Using the marginal cost accounting in Equation(4) and standard arguments. t )+Π RB. t )+K 1(Q RB

T L. t=1. Proof of Lemma 1. Using the marginal cost accounting in Equation(4) and standard arguments. t )+Π RB. t )+K 1(Q RB Elecronic Companion EC.1. Proofs of Technical Lemmas and Theorems LEMMA 1. Le C(RB) be he oal cos incurred by he RB policy. Then we have, T L E[C(RB)] 3 E[Z RB ]. (EC.1) Proof of Lemma 1. Using he marginal

More information

Some Ramsey results for the n-cube

Some Ramsey results for the n-cube Some Ramsey resuls for he n-cube Ron Graham Universiy of California, San Diego Jozsef Solymosi Universiy of Briish Columbia, Vancouver, Canada Absrac In his noe we esablish a Ramsey-ype resul for cerain

More information

Inventory Analysis and Management. Multi-Period Stochastic Models: Optimality of (s, S) Policy for K-Convex Objective Functions

Inventory Analysis and Management. Multi-Period Stochastic Models: Optimality of (s, S) Policy for K-Convex Objective Functions Muli-Period Sochasic Models: Opimali of (s, S) Polic for -Convex Objecive Funcions Consider a seing similar o he N-sage newsvendor problem excep ha now here is a fixed re-ordering cos (> 0) for each (re-)order.

More information

Reading from Young & Freedman: For this topic, read sections 25.4 & 25.5, the introduction to chapter 26 and sections 26.1 to 26.2 & 26.4.

Reading from Young & Freedman: For this topic, read sections 25.4 & 25.5, the introduction to chapter 26 and sections 26.1 to 26.2 & 26.4. PHY1 Elecriciy Topic 7 (Lecures 1 & 11) Elecric Circuis n his opic, we will cover: 1) Elecromoive Force (EMF) ) Series and parallel resisor combinaions 3) Kirchhoff s rules for circuis 4) Time dependence

More information

t is a basis for the solution space to this system, then the matrix having these solutions as columns, t x 1 t, x 2 t,... x n t x 2 t...

t is a basis for the solution space to this system, then the matrix having these solutions as columns, t x 1 t, x 2 t,... x n t x 2 t... Mah 228- Fri Mar 24 5.6 Marix exponenials and linear sysems: The analogy beween firs order sysems of linear differenial equaions (Chaper 5) and scalar linear differenial equaions (Chaper ) is much sronger

More information

4.1 - Logarithms and Their Properties

4.1 - Logarithms and Their Properties Chaper 4 Logarihmic Funcions 4.1 - Logarihms and Their Properies Wha is a Logarihm? We define he common logarihm funcion, simply he log funcion, wrien log 10 x log x, as follows: If x is a posiive number,

More information

6.302 Feedback Systems Recitation : Phase-locked Loops Prof. Joel L. Dawson

6.302 Feedback Systems Recitation : Phase-locked Loops Prof. Joel L. Dawson 6.32 Feedback Syem Phae-locked loop are a foundaional building block for analog circui deign, paricularly for communicaion circui. They provide a good example yem for hi cla becaue hey are an excellen

More information

Mon Apr 2: Laplace transform and initial value problems like we studied in Chapter 5

Mon Apr 2: Laplace transform and initial value problems like we studied in Chapter 5 Mah 225-4 Week 2 April 2-6 coninue.-.3; alo cover par of.4-.5, EP 7.6 Mon Apr 2:.-.3 Laplace ranform and iniial value problem like we udied in Chaper 5 Announcemen: Warm-up Exercie: Recall, The Laplace

More information

Chapter 2. First Order Scalar Equations

Chapter 2. First Order Scalar Equations Chaper. Firs Order Scalar Equaions We sar our sudy of differenial equaions in he same way he pioneers in his field did. We show paricular echniques o solve paricular ypes of firs order differenial equaions.

More information

Interpolation and Pulse Shaping

Interpolation and Pulse Shaping EE345S Real-Time Digial Signal Proceing Lab Spring 2006 Inerpolaion and Pule Shaping Prof. Brian L. Evan Dep. of Elecrical and Compuer Engineering The Univeriy of Texa a Auin Lecure 7 Dicree-o-Coninuou

More information

Additional Methods for Solving DSGE Models

Additional Methods for Solving DSGE Models Addiional Mehod for Solving DSGE Model Karel Meren, Cornell Univeriy Reference King, R. G., Ploer, C. I. & Rebelo, S. T. (1988), Producion, growh and buine cycle: I. he baic neoclaical model, Journal of

More information

Network Flow Applications

Network Flow Applications Hopial problem Neork Flo Applicaion Injured people: n Hopial: k Each peron need o be brough o a hopial no more han 30 minue aay Each hopial rea no more han n/k" people Gien n, k, and informaion abou people

More information