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 Reduce Prolem A o Prolem B Conver an inance of Prolem A o an inance Prolem B Ue a oluion of Prolem B o ge a oluion o Prolem A Pracical Ue a program for Prolem B o olve Prolem A Theoreical Show ha Prolem B i a lea a hard a Prolem A Prolem Reducion Example Reduce he prolem of finding he Maximum of a e of ineger o finding he Minimum of a e of ineger Find he maximum of: 8, -,,,, -6 Conruc an equivalen minimizaion prolem Undireced Nework Flow Undireced graph wih edge capaciie Flow may go eiher direcion along he edge (ujec o he capaciy conrain) u Biparie Maching A graph G=(V,E) i iparie if he verice can e pariioned ino dijoin e X,Y A maching M i a ue of he edge ha doe no hare any verice 5 Find a maching a large a poile v Conruc an equivalen flow prolem
Applicaion A collecion of eacher A collecion of coure And a graph howing which eacher can each which coure RA 0 Convering Maching o Nework Flow PB CC DG AK 6 0 Finding edge dijoin pah Theorem The maximum numer of edge dijoin pah equal he minimum numer of edge whoe removal eparae from Conruc a maximum cardinaliy e of edge dijoin pah Circulaion Prolem Direced graph wih capaciie, c(e) on he edge, and demand d(v) on verice Find a flow funcion ha aifie he capaciy conrain and he verex demand 0 <= f(e) <= c(e) u f in (v) f ou (v) = d(v) Circulaion fac: Feaiiliy prolem 5 d(v) < 0: ource; d(v) > 0: ink Mu have Σ v d(v)=0 o e feaile v -5 Find a circulaion in he following graph - a e 6 5 7 0 c f h 9 8 d 5 g -5
Reducing he circulaion prolem o Nework flow 5 a u v -5 Formal reducion Add ource node, and ink node For each node v, wih d(v) < 0, add an edge from o v wih capaciy -d(v) For each node v, wih d(v) > 0, add an edge from v o wih capaciy d(v) Find a maximum - flow. If hi flow ha ize Σ v cap(,v) hen he flow give a circulaion aiifying he demand Circulaion wih loweround on flow on edge Each edge ha a loweround l(e). The flow f mu aify l(e) <= f(e) <= c(e) Removing loweround on edge Loweround can e hifed o he demand a, x y -,5 0,, -, y y Formal reducion L in (v): um of loweround on incoming edge L ou (v): um of loweround on ougoing edge Creae new demand d and capaciie c on verice and edge d (v) = d(v) + l ou (v) l in (v) c (e) = c(e) l(e) Applicaion Cuomized urvey Ak cuomer aou produc Only ak cuomer aou produc hey ue Limied numer of queion you can ak each cuomer Need o ak a cerain numer of cuomer aou each produc Informaion availale aou which produc each cuomer ha ued
Deail Circulaion conrucion Cuomer C,..., C n Produc P,..., P m S i i he e of produc ued y C i Cuomer C i can e aked eween c i and c i queion Queion aou produc P j mu e aked on eween p j and p j urvey Today opic Open Pi Mining Prolem Tak Selecion Prolem Reducion o Min Cu prolem S, T i a cu if S, T i a pariion of he verice wih in S and in T The capaciy of an S, T cu i he um of he capaciie of all edge going from S o T Open Pi Mining Each uni of earh ha a profi (poily negaive) Geing o he ore elow he urface require removing he dir aove Te drilling give reaonale eimae of co Plan an opimal mining operaion Mine Graph Deermine an opimal mine -5 - - - - - -7 - - - - - - - - - - -7 7 8 6 8 6 -
Precedence graph G=(V,E) Each v in V ha a profi p(v) A e F if feaile if when w in F, and (v,w) in E, hen v in F. Find a feaile e o maximize he profi Generalizaion - 6 5 - - Min cu algorihm for profi maximizaion Conruc a flow graph where he minimum cu idenifie a feaile e ha maximize profi Precedence graph conrucion Precedence graph G=(V,E) Each edge in E ha infinie capaciy Add verice, Each verex in V i aached o and wih finie capaciy edge Show a finie value cu wih a lea wo verice on each ide of he cu Infinie Finie The ink ide of a finie cu i a feaile e No edge permied from S o T If a verex i in T, all of i anceor are in T If p(v) > 0, cap(v,) = p(v) cap(,v) = 0 If p(v) < 0 cap(,v) = -p(v) cap(v,) = 0 If p(v) = 0 cap(,v) = 0 cap(v,) = 0 Seing he co - - - 0
Enumerae all finie, cu and how heir capaciie Minimum cu give opimal oluion Why? Compuing he Profi Co(W) = Σ {w in W; p(w) < 0} -p(w) Benefi(W) = Σ {w in W; p(w) > 0} p(w) Profi(W) = Benefi(W) Co(W) Expre Cap(S,T) in erm of B, C, Co(T), Benefi(T), and Profi(T) Maximum co and enefi C = Co(V) B = Benefi(V) Summary Conruc flow graph Infinie capaciy for precedence edge Capaciie o ource/ink aed on co/enefi Finie cu give a feaile e of ak Minimizing he cu correpond o maximizing he profi Find minimum cu wih a nework flow algorihm Today opic More nework flow reducion Airplane cheduling Image egmenaion Baeall eliminaion
Airplane Scheduling Given an airline chedule, and aring locaion for he plane, i i poile o ue a fixed e of plane o aify he chedule. Schedule [egmen] Deparure, arrival pair (ciie and ime) Approach Conruc a circulaion prolem where pah of flow give egmen flown y each plane Example Seale->San Francico, 9:00 :00 Seale->Denver, 8:00 :00 San Francico -> Lo Angele, :00 :00 Sal Lake Ciy -> Lo Angele, 5:00-7:00 San Diego -> Seale, 7:0-> :00 Lo Angele -> Seale, 8:00->:00 Fligh ime: Denver->Sal Lake Ciy, hour Lo Angele->San Diego, hour Can hi chedule e full filled wih wo plane, aring from Seale? Compaile egmen Segmen S and S are compaile if he ame plane can e ued on S and S End of S equal ar of S, and enough ime for urn around eween arrival and deparure ime End of S i differen from S, u here i enough ime o fly eween ciie Graph repreenaion Each egmen, S i, i repreened a a pair of verice (d i, a i, for deparure and arrival), wih an edge eween hem. d i Add an edge eween a i and d j if S i i compaile wih S j. a i a i d j Seing up a flow prolem Reul d i, a i The plane can aify he chedule iff here i a feaile circulaion 0, a i d j - P i P i
Image Segmenaion Separae foreground from ackground Image analyi a i : value of aigning pixel i o he foreground i : value of aigning pixel i o he ackground p ij : penaly for aigning i o he foreground, j o he ackground or vice vera A: foreground, B: ackground Q(A,B) = Σ {i in A} a i + Σ {j in B} j - Σ {(i,j) in E, i in A, j in B} p ij Pixel graph o flow graph Mincu Conrucion Baeall eliminaion a v u p vu p uv v Can he Dinoaur win he league? Remaining game: AB, AC, AD, AD, AD, BC, BC, BC, BD, CD W L An Bee Cockroache Dinoaur 5 v A eam win he league if i ha ricly more win han any oher eam a he end of he eaon A eam ie for fir place if no eam ha more win, and here i ome oher eam wih he ame numer of win
Baeall eliminaion Can he Frui Flie win he league? Remaining game: AC, AD, AD, AD, AF, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, BF, CE, CE, CE, CF, CF, DE, DF, EF, EF W L An 7 Bee 6 7 Cockroache 6 7 Dinoaur Earhworm Frui Flie 5 Aume Frui Flie win remaining game Frui Flie are ied for fir place if no eam win more han 9 game Allowale win An () Bee () Cockroache () Dinoaur (5) Earhworm (5) 8 game o play AC, AD, AD, AD, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, CE, CE, CE, DE W L An 7 Bee 6 8 Cockroache 6 9 Dinoaur Earhworm Frui Flie 9 5 Remaining game AC, AD, AD, AD, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, CE, CE, CE, DE AC AD BC BD BE CE DE A B C D E Nework flow applicaion ummary Biparie Maching Dijoin Pah Airline Scheduling Survey Deign Baeall Eliminaion Projec Selecion Image Segmenaion T