Chaper. Biparie Maching Nework Flow Slide by Kevin Wayne. Copyrigh @ PearonAddion Weley. All righ reerved. Maching Biparie 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. Biparie maching. Inpu: undireced, biparie graph G = (L R, E). M " E i a maching if each node appear in a mo edge in M. Max maching: find a max cardinaliy maching. ' ' ' maching ', ', ' ' L ' R
Biparie Maching Biparie Maching Biparie maching. Inpu: undireced, biparie graph G = (L R, E). M " E i a maching if each node appear in a mo edge in M. Max maching: find a max cardinaliy maching. Max flow formulaion. Creae digraph G' = (L R {, }, E' ). Direc all edge from L o R, and aign infinie (or uni) capaciy. Add ource, and uni capaciy edge from o each node in L. Add ink, and uni capaciy edge from each node in R o. ' G' ' ' max maching ', ', ' ' ' ' ' ' ' L ' R L ' R Biparie Maching: Proof of Correcne Biparie Maching: Proof of Correcne Theorem. Max cardinaliy maching in G = value of max flow in G'. Pf. $ Given max maching M of cardinaliy k. Conider flow f ha end uni along each of k pah. f i a flow, and ha cardinaliy k. Theorem. Max cardinaliy maching in G = value of max flow in G'. Pf. % Le f be a max flow in G' of value k. Inegraliy heorem & k i inegral and can aume f i. Conider M = e of edge from L o R wih f(e) =. each node in L and R paricipae in a mo one edge in M M = k: conider cu (L, R ) ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' G ' ' G' G' ' ' G 8
Perfec Maching Perfec Maching Def. A maching M " E i perfec if each node appear in exacly one edge in M. Noaion. Le S be a ube of node, and le N(S) be he e of node adjacen o node in S. Q. When doe a biparie graph have a perfec maching? Srucure of biparie graph wih perfec maching. Clearly we mu have L = R. Wha oher condiion are neceary? Wha condiion are ufficien? Obervaion. If a biparie graph G = (L R, E), ha a perfec maching, hen N(S) % S for all ube S " L. Pf. Each node in S ha o be mached o a differen node in N(S). ' ' ' No perfec maching: S = {,, } N(S) = { ', ' }. ' L ' R 9 Marriage Theorem Proof of Marriage Theorem Marriage Theorem. [Frobeniu 9, Hall 9] Le G = (L R, E) be a biparie graph wih L = R. Then, G ha a perfec maching iff N(S) % S for all ube S " L. Pf. & Thi wa he previou obervaion. L ' ' ' ' ' R No perfec maching: S = {,, } N(S) = { ', ' }. Pf. ' Suppoe G doe no have a perfec maching. Formulae a a max flow problem and le (A, B) be min cu in G'. By maxflow mincu, cap(a, B) < L. Define L A = L ( A, L B = L ( B, R A = R ( A. cap(a, B) = L B + R A. Since min cu can' ue edge: N(L A ) " R A. N(L A ) $ R A = cap(a, B) L B < L L B = L A. Chooe S = L A. G' A ' ' ' L A = {,, } ' L B = {, } R A = {', '} ' N(L A ) = {', '}
Biparie Maching: Running Time Which max flow algorihm o ue for biparie maching? Generic augmening pah: O(m val(f*) ) = O(mn). Capaciy caling: O(m log C ) = O(m ). Shore augmening pah: O(m n / ).. Dijoin Pah Nonbiparie maching. Srucure of nonbiparie graph i more complicaed, bu wellunderood. [TueBerge, EdmondGalai] Bloom algorihm: O(n ). [Edmond 9] Be known: O(m n / ). [MicaliVazirani 98] Edge Dijoin Pah Edge Dijoin Pah Dijoin pah problem. Given a digraph G = (V, E) and wo node and, find he max number of edgedijoin pah. Dijoin pah problem. Given a digraph G = (V, E) and wo node and, find he max number of edgedijoin pah. Def. Two pah are edgedijoin if hey have no edge in common. Def. Two pah are edgedijoin if hey have no edge in common. Ex: communicaion nework. Ex: communicaion nework.
Edge Dijoin Pah Edge Dijoin Pah Max flow formulaion: aign uni capaciy o every edge. Max flow formulaion: aign uni capaciy o every edge. Theorem. Max number edgedijoin pah equal max flow value. Pf. $ Suppoe here are k edgedijoin pah P,..., P k. Se f(e) = if e paricipae in ome pah P i ; ele e f(e) =. Since pah are edgedijoin, f i a flow of value k. Theorem. Max number edgedijoin pah equal max flow value. Pf. % Suppoe max flow value i k. Inegraliy heorem & here exi flow f of value k. Conider edge (, u) wih f(, u) =. by conervaion, here exi an edge (u, v) wih f(u, v) = coninue unil reach, alway chooing a new edge Produce k (no necearily imple) edgedijoin pah. can eliminae cycle o ge imple pah if deired 8 Nework Conneciviy Edge Dijoin Pah and Nework Conneciviy Nework conneciviy. Given a digraph G = (V, E) and wo node and, find min number of edge whoe removal diconnec from. Theorem. [Menger 9] The max number of edgedijoin pah i equal o he min number of edge whoe removal diconnec from. Def. A e of edge F " E diconnec from if all pah ue a lea on edge in F. Pf. $ Suppoe he removal of F " E diconnec from, and F = k. All pah ue a lea one edge of F. Hence, he number of edgedijoin pah i a mo k. 9
Dijoin Pah and Nework Conneciviy Theorem. [Menger 9] The max number of edgedijoin pah i equal o he min number of edge whoe removal diconnec from.. Exenion o Max Flow Pf. % Suppoe max number of edgedijoin pah i k. Then max flow value i k. Maxflow mincu & cu (A, B) of capaciy k. Le F be e of edge going from A o B. F = k and diconnec from. A Circulaion wih Demand Circulaion wih Demand Circulaion wih demand. Direced graph G = (V, E). Edge capaciie c(e), e ) E. Node upply and demand d(v), v ) V. Neceary condiion: um of upplie = um of demand. d(v) v : d (v) > " = " d(v) =: D v : d (v) < Pf. Sum conervaion conrain for every demand node v. demand if d(v) > ; upply if d(v) < ; ranhipmen if d(v) = Def. A circulaion i a funcion ha aifie: For each e ) E: $ f(e) $ c(e) (capaciy) For each v ) V: " f (e) " f (e) = d(v) (conervaion) e in o v e ou of v Circulaion problem: given (V, E, c, d), doe here exi a circulaion? 8 upply flow 9 capaciy demand
Circulaion wih Demand Circulaion wih Demand Max flow formulaion. Max flow formulaion. Add new ource and ink. For each v wih d(v) <, add edge (, v) wih capaciy d(v). For each v wih d(v) >, add edge (v, ) wih capaciy d(v). Claim: G ha circulaion iff G' ha max flow of value D. aurae all edge leaving and enering G: 8 upply G': 8 upply 9 9 demand demand Circulaion wih Demand Circulaion wih Demand and Lower Bound Inegraliy heorem. If all capaciie and demand are ineger, and here exi a circulaion, hen here exi one ha i inegervalued. Pf. Follow from max flow formulaion and inegraliy heorem for max flow. Characerizaion. Given (V, E, c, d), here doe no exi a circulaion iff here exi a node pariion (A, B) uch ha * v)b d v > cap(a, B) Feaible circulaion. Direced graph G = (V, E). Edge capaciie c(e) and lower bound l (e), e ) E. Node upply and demand d(v), v ) V. Def. A circulaion i a funcion ha aifie: For each e ) E: l (e) $ f(e) $ c(e) (capaciy) " f (e) " f (e) = d(v) For each v ) V: (conervaion) e in o v e ou of v Pf idea. Look a min cu in G'. demand by node in B exceed upply of node in B plu max capaciy of edge going from A o B Circulaion problem wih lower bound. Given (V, E, l, c, d), doe here exi a a circulaion? 8
Circulaion wih Demand and Lower Bound Idea. Model lower bound wih demand. Send l(e) uni of flow along edge e..8 Survey Deign Updae demand of boh endpoin. lower bound upper bound capaciy v [, 9] w d(v) d(w) d(v) + d(w) G G' v w Theorem. There exi a circulaion in G iff here exi a circulaion in G'. If all demand, capaciie, and lower bound in G are ineger, hen here i a circulaion in G ha i inegervalued. Pf kech. f(e) i a circulaion in G iff f'(e) = f(e) l(e) i a circulaion in G'. 9 Survey Deign Survey Deign Survey deign. Deign urvey aking n conumer abou n produc. Can only urvey conumer i abou a produc j if hey own i. Ak conumer i beween c i and c i ' queion. Ak beween p j and p j ' conumer abou produc j. Algorihm. Formulae a a circulaion problem wih lower bound. Include an edge (i, j) if cuomer own produc i. Ineger circulaion + feaible urvey deign. [, ] Goal. Deign a urvey ha mee hee pec, if poible. [, ] ' Biparie perfec maching. Special cae when c i = c i ' = p i = p i ' =. [c, c '] ' [p, p '] ' ' conumer ' produc
Image Segmenaion. Image Segmenaion Image egmenaion. Cenral problem in image proceing. Divide image ino coheren region. Ex: Three people anding in fron of complex background cene. Idenify each peron a a coheren objec. Image Segmenaion Image Segmenaion Foreground / background egmenaion. Label each pixel in picure a belonging o foreground or background. V = e of pixel, E = pair of neighboring pixel. a i % i likelihood pixel i in foreground. b i % i likelihood pixel i in background. p ij % i eparaion penaly for labeling one of i and j a foreground, and he oher a background. Goal. Accuracy: if a i > b i in iolaion, prefer o label i in foreground. Smoohne: if many neighbor of i are labeled foreground, we hould be inclined o label i a foreground. Find pariion (A, B) ha maximize: a i + b j i " A j " B foreground background $ p ij (i, j) " E AI{i, j} = Formulae a min cu problem. Maximizaion. No ource or ink. Undireced graph. Turn ino minimizaion problem. Maximizing a i + b j i " A j " B i equivalen o minimizing $ p ij (i, j) " E AI{i, j} = ( i " V a + b i j " V ) j or alernaively a j + b i + p ij j " B a conan i " A (i, j) " E AI{i, j} = $ a i $ b j i" A j " B + p ij (i, j) " E AI{i,j} =
Image Segmenaion Image Segmenaion Formulae a min cu problem. G' = (V', E'). Add ource o correpond o foreground; add ink o correpond o background Ue wo aniparallel edge inead of undireced edge. p ij p ij p ij Conider min cu (A, B) in G'. A = foreground. cap(a, B) = a j + b i + p ij j " B i" A (i, j) " E i" A, j " B Preciely he quaniy we wan o minimize. if i and j on differen ide, p ij couned exacly once a j a j i p ij j i p ij j b i A b i G' G' 8 Projec Selecion. Projec Selecion Projec wih prerequiie. can be poiive or negaive Se P of poible projec. Projec v ha aociaed revenue p v. ome projec generae money: creae ineracive ecommerce inerface, redeign web page oher co money: upgrade compuer, ge ie licene Se of prerequiie E. If (v, w) ) E, can' do projec v and unle alo do projec w. A ube of projec A " P i feaible if he prerequiie of every projec in A alo belong o A. Projec elecion. Chooe a feaible ube of projec o maximize revenue.
Projec Selecion: Prerequiie Graph Projec Selecion: Min Cu Formulaion Prerequiie graph. Include an edge from v o w if can' do v wihou alo doing w. {v, w, x} i feaible ube of projec. {v, x} i infeaible ube of projec. Min cu formulaion. Aign capaciy o all prerequiie edge. Add edge (, v) wih capaciy pv if pv >. Add edge (v, ) wih capaciy pv if pv <. For noaional convenience, define p = p =. w w u v v x x feaible pu py y pw z pv pz px v infeaible w x Projec Selecion: Min Cu Formulaion Open Pi Mining Claim. (A, B) i min cu iff A, { } i opimal e of projec. Infinie capaciy edge enure A, { } i feaible. Max revenue becaue: cap(a, B) = p v + ($ p v ) Openpi mining. (udied ince early 9) Block of earh are exraced from urface o rerieve ore. Each block v ha ne value pv = value of ore proceing co. Can' remove block v before w or x. v" B: pv > = v" A: pv < pv $ pv v: pv > v " A conan w A u pu w pw py pv y z v x v px x
Baeball Eliminaion. Baeball Eliminaion Again = rij Team i Win wi Loe li To play ri Al Phi NY Alana 8 8 Philly 8 9 Some reporer aked him o figure ou he mahemaic of New York 8 8 he pennan race. You know, one eam win o many of heir Monreal 8 "See ha hing in he paper la week abou Einein?... remaining game, he oher eam win hi number or ha Mon number. Wha are he myriad poibiliie? Who' go he Which eam have a chance of finihing he eaon wih mo win? Monreal eliminaed ince i can finih wih a mo 8 win, bu Alana already ha 8. wi + ri < wj & eam i eliminaed. Only reaon por wrier appear o be aware of. Sufficien, bu no neceary edge?" "The hell doe he know?" "Apparenly no much. He picked he Dodger o eliminae he Gian la Friday." Don DeLillo, Underworld Baeball Eliminaion Baeball Eliminaion Again = rij Team i Win wi Loe li To play ri Al Phi NY Alana 8 8 Philly 8 9 New York 8 8 Monreal 8 Mon Which eam have a chance of finihing he eaon wih mo win? Philly can win 8, bu ill eliminaed... If Alana loe a game, hen ome oher eam win one. Remark. Anwer depend no ju on how many game already won and lef o play, bu alo on whom hey're again. 8
Baeball Eliminaion Baeball Eliminaion: Max Flow Formulaion Baeball eliminaion problem. Se of eam S. Diinguihed eam ) S. Team x ha won w x game already. Team x and y play each oher r xy addiional ime. I here any oucome of he remaining game in which eam finihe wih he mo (or ied for he mo) win? Can eam finih wih mo win? Aume eam win all remaining game & w + r win. Divvy remaining game o ha all eam have $ w + r win. game lef eam can ill win hi many more game r = w + r w 9 game node eam node Baeball Eliminaion: Max Flow Formulaion Baeball Eliminaion: Explanaion for Spor Wrier Theorem. Team i no eliminaed iff max flow aurae all edge leaving ource. Inegraliy heorem & each remaining game beween x and y added o number of win for eam x or eam y. Capaciy on (x, ) edge enure no eam win oo many game. Team i Win w i Loe To play Again = r ij l i NY Bal Bo Tor NY 9 8 8 Balimore 8 Boon 9 8 Torono Deroi 9 8 r i De game lef r = w + r w eam can ill win hi many more game AL Ea: Augu, 99 Which eam have a chance of finihing he eaon wih mo win? Deroi could finih eaon wih 9 + = win. game node eam node
Baeball Eliminaion: Explanaion for Spor Wrier Baeball Eliminaion: Explanaion for Spor Wrier Team i Win w i Which eam have a chance of finihing he eaon wih mo win? Deroi could finih eaon wih 9 + = win. Cerificae of eliminaion. R = {NY, Bal, Bo, Tor} Have already won w(r) = 8 game. Mu win a lea r(r) = more. Loe To play Again = r ij l i NY Bal Bo Tor NY 9 8 8 Balimore 8 Boon 9 8 Torono Deroi 9 8 Average eam in R win a lea / > game. r i AL Ea: Augu, 99 De Cerificae of eliminaion. If remaining game win 8 8 T " S, w(t ) := $ w i, g(t ) := $ g x y, it {x, y} " T LB on avg game won 8 w(t)+ g(t) T > w z + g z hen z i eliminaed (by ube T). Theorem. [HoffmanRivlin 9] Team z i eliminaed iff here exi a ube T* ha eliminae z. Proof idea. Le T* = eam node on ource ide of min cu. Baeball Eliminaion: Explanaion for Spor Wrier Baeball Eliminaion: Explanaion for Spor Wrier Pf of heorem. Ue max flow formulaion, and conider min cu (A, B). Define T* = eam node on ource ide of min cu. Oberve xy ) A iff boh x ) T* and y ) T*. infinie capaciy edge enure if xy ) A hen x ) A and y ) A if x ) A and y ) A bu xy ) T, hen adding xy o A decreae capaciy of cu Pf of heorem. Ue max flow formulaion, and conider min cu (A, B). Define T* = eam node on ource ide of min cu. Oberve xy ) A iff boh x ) T* and y ) T*. g(s " {z}) > cap(a, B) capaciy of game edge leaving capaciy of eam edge leaving 8 8 = g(s " {z})" g(t*) + $ (w z + g z " w x ) x T* = g(s " {z})" g(t*) " w(t*) + T* (w z + g z ) game lef y eam x can ill win hi many more game w(t*)+ g(t*) Rearranging erm: w z + g z < T* r xy = x w z + r z w x
kregular Biparie Graph Exra Slide Dancing problem. Excluive Ivy league pary aended by n men and n women. Each man know exacly k women; each woman know exacly k men. Acquainance are muual. I i poible o arrange a dance o ha each woman dance wih a differen man ha he know? Mahemaical reformulaion. Doe every kregular biparie graph have a perfec maching? ' ' Ex. Boolean hypercube. ' ' women ' men 8 kregular Biparie Graph Have Perfec Maching Cenu Tabulaion Theorem. [König 9, Frobeniu 9] Every kregular biparie graph ha a perfec maching. Pf. Size of max maching = value of max flow in G'. Conider flow: /k if (u, v) " E % f (u, v) = $ if u = or v = % & oherwie f i a flow and i value = n & perfec maching. Feaible marix rounding. Given a pbyq marix D = {d ij } of real number. Row i um = a i, column j um b j. Round each d ij, a i, b j up or down o ineger o ha um of rounded elemen in each row (column) equal row (column) um. Original applicaion: publihing US Cenu daa. Goal. Find a feaible rounding, if one exi. /k ' flow f '..8.. G' ' 9........ '... ' original marix feaible rounding 9
Cenu Tabulaion Cenu Tabulaion Feaible marix rounding. Given a pbyq marix D = {d ij } of real number. Row i um = a i, column j um b j. Round each d ij, a i, b j up or down o ineger o ha um of rounded elemen in each row (column) equal row (column) um. Original applicaion: publihing US Cenu daa. Goal. Find a feaible rounding, if one exi. Remark. "Threhold rounding" can fail........9.9.9.. Theorem. Feaible marix rounding alway exi. Pf. Formulae a a circulaion problem wih lower bound. Original daa provide circulaion (all demand = ). Inegraliy heorem & inegral oluion & feaible rounding...8. 9............, 8,, lower bound,, upper bound ' ',,, original marix feaible rounding row ' column