Lecture #12:0.0.1 Graph Algorithms: Maximum Flow (Chapter 26)Given a directed graph G =(V,E) in which each edge (u, v) ∈ E has a capacityc(u, v) ≥ 0.If(u, v) /∈ E we assume that c(u, v)=0. We also distinguish twovertices s (origin = source) and t (destination = sink). A flow in G is a functionf : V × V −→ R that satisfies the follo wing three properties:Capacity Constrain t: f(u, v) ≤ c(u, v)∀u, v ∈ VSkew symmetry: f(v, u)=−f(u, v)∀u, v ∈ VFlow conservation:Pv∈Vf(u, v)=0∀u ∈ V − {s, t}f(u, v) is called the net flow from u to v.Thevalueoff denoted by |f| isequal toPv∈Vf(s, v).In the maxim u m flow problem,wewanttheflow f with maxim um |f| .For example, consider the following problem:cbas td1613104204714912The following is a flow:cbas td11/168/13101/415/204/47/711/144/912/12The value of this flow is 19.1Cancellation: Consider the following diagram:ba104ba8/104ba8/103/4ba5/104ba102/4In the first diagram, we have the capacities; the second has a flow of 8 froma to b; the third has an additional flow of 3 from b to a; cancelling the flowin both directions gives us the next diagram with 5 from a to b, and none inthe other direction. Finally, an additional flow of 7 from b to a, cancels theprevious flow and introduces a flow of 2 from b to a.Because of this, we define the concept of residual capacity as follows:cf(u, v)=c(u, v) − f(u, v). The residual capacity for the above case w ould looklike:ba104ba212ba59ba59ba122And a residual network as follows: Given a flow network G =(V,E), c :E −→ R+,andaflow f , the residual network Gf=(V,Ef) where Ef={(u, v) ∈ V × V : cf(u, v) > 0}. Please note that Efmay contain edgesnot present in E. The main step of the algorithm is to find a directed pathfrom s to t in Gfcalled an augmenting path and saturate it. To saturate apath P ,weaddaflow equal to min(u,v)∈P[cf(u, v)] along the path. This stepis repeated until there is no such path. Please note that after any flow change,2you must redefine the residual network. We show all this b y an example below:cbas td1613104204714912cbas td4131048471491212 12cbas td1613104204714912cbas td12/161310412/204714912/12cbas td44/1310484/474/1491212 12cbas td491048471091212 1244cbas td47/91047/847/77/1091212 1244cbas td42104147391212 191111cbas td12/1611/1310419/204/47/711/14912/12Residual networks are on the left column and flows on the right. The laststep does not have a path in the residual network. The solution at this time isoptimal.The path is the residual network is found using BFS and BFS is shown3below:S1/BIC HGEFDS1B2IC2HGEFD B CQS1B2IC2HGE3FD C EQS1B2IC2HGE3F3D3E DQFS1B2IC2H4G4E3F3D3GDQF HS1B2IC2H4G4E3F3D3GQF HS1B2IC2H4G4E3F3D3GQHS1B2I5C2H4G4E3F3D3IQHS1B2I5C2H4G4E3F3D3IQS1B2I5C2H4G4E3F3D3Q is emptyProofs:Let f(X, Y )=Pu∈Xv∈Y[f(u, v)].Thenitiseasytoshow:f(X, X)=0∀X ⊆ Vf(X, Y )=−f(Y,X)∀X, Y ⊆ Vf(X ∪ Y, Z)=f(X, Z)+f(Y,Z)∀X, Y, Z ⊆ V ; X ∩ Y = φf(Z, X ∪ Y )=f(Z, X)+f(Z, Y )∀X, Y, Z ⊆ V ; X ∩ Y = φUsingthisitiseasytoshowthat|f| = f(s, V )=f (V,t)Lemma 1 Let f be a flow in G =[V, E] from s to t.Letf0be a flow in theresidual network Gfinduced by f .Thenf + f0is a flow in G with a value|f + f0| = |f| + |f0|4Proof.(f + f0)(u, v)=f(u, v)+f0(u, v)= −f(v, u) − f0(v, u)= −(f(v, u)+f0(v,u))= −(f + f0)(u, v)(f + f0)(u, v)=f(u, v)+f0(u, v)≤ f(u, v)+[cf(u, v) − f(u, v)]= c(u, v)since f0(u, v) ≤ cf(u, v)=c(u, v) − f(u, v). For all u ∈ V − {s} − {t}Xv∈V(f + f0)(u, v)=Xv∈Vf(u, v)+Xv∈Vf0(u, v)=0+0=0Finally|f + f0| =Xv∈V(f + f0)(s, v)=Xv∈Vf(s, v)+Xv∈Vf0(s, v)= |f| + |f0|Acut(S, V −S) separates s and t if s ∈ S and t ∈ V −S.IfweletT = V −S,the capacity of the cut (S, T ) is c(S, T ). Recall by our notationc(S, T )=Xu∈Sv∈Tc(u, v)Lemma 2 For any cut (S, T ) and any flow f,wehavef(S, T )=|f|Proof.f(S, T )=f(S, V ) − f(S, S)= f(S, V )= f(s, V )+f(S − s, V )= f(s, V )= |f|Lemma 3 For any flow f and any cut (S, T ), |f| ≤ c(S, T )5Proof.|f| = f(S, T )=Xu∈Sv∈Tf(u, v)≤Xu∈Sv∈Tc(u, v)=c(S, T )Theorem 4 Given a flow f in G =[V,E] and s, t,as above, the following areequivalent"1. f is a maximum flow in G from s to t.2. The r esidual network Gfcontains no directe d path from s to t.[Suchapath is called an augmenting path]3. |f| = c(S, T ) for some cut (S, T ) separating s and t.Proof. (1) =⇒ (2) : Suppose f is maximum and there is an augmentingpath p.Letfpbe the flow that this path can take — notefp= cf(p)= min(u,v)∈p[cf(u, v) > 0The f + fpis a flow in G with a greater value and this is a contradiction to |f|being maximum.(2) =⇒ (3) : Suppose Gfhas no directed path from s to t.LetS = {v ∈ V :there is a directed path from s to v in Gf}.LetT = V = S. (S, T ) is a cutseparating s and t.[u ∈ S, v ∈ T ]=⇒ [cf(u, v)=0]=⇒ [f(u, v)=c(u, v)]Hence|f| = f(S, T )= c(S, T )(3) =⇒ (1) : For any feasible flow g, and any cut (X, V − X) separating sand t,wehave|g| ≤ c(X, V − X). Hence if we ha ve a flow f and a cut (S, T )separating s and t with |f| = c(S, T ), then this flow is maximum and this cutis minimum.0.0.2 Edmonds-Karp AlgorithmThis algorithm finds at each step a flow augmenting path which has as few edgesas possible. This is done by using BFS on the graph Gf.Wewillnowshowthatif augmentations are done in this manner, the number of flo w augmentations(and the whole algorithm) are polynomially bounded.6Lemma 5 If the E-K algorithm is run on a flow network G =[V,E] with sources and sink t, then for all vertices v ∈ V − {s}, the shortest distance δ(s, v) inthe residual network Gf(measured by the number of edges) never decreases.Proof. Suppose not. Let δf0(s, v) <δf(s, v) where f is the flow before andf0is the flow after some augmentation. Further suppose[δf0(s, u) <δf0(s, v)] =⇒ [δf(s, u) ≤ δf0(s, v)]Let p0be a shortest path from s to v in Gf0with u asthenodebeforev. Henceδf0(s, u)=δf0(s, v) − 1andδf(s, u) ≤ δf0(s, u)If before the augmentation f0, f[u, v] <c[u, v],thenδf(s, v) ≤ δf(s, u)+1≤ δf0(s, u)+1=δf0(s, v)which contradicts our s upposition. So f[u, v]=c[u, v] before augmentation f0.This implis that (u, v) /∈ Ef. But augmenting path p in Gfchosen to produceGf0must contain edge (v, u) in the direction from v to u since (u, v) ∈ Ef0(bysupposition) and (u, v) /∈ Efas we have shown. Since p is a shortest path froms to t, its subpaths are also shortest paths. Henceδf(s, v)=δf(s, u) − 1 ≤ δf0(s, u) − 1=δf0(s, v) − 2 <δf0(s, v)and this is a
View Full Document