CS138A Network Flows Peter Schröder
CS138A Flow Networks Definitions a flow network G=(V,E) is a directed graph in which each edge (u,v) in E has a nonnegative capacity c(u,v) there are two distinguished vertices: a source s and a sink t for simplicity assume that every vertex lies on some path from s to t (this implies that the graph is connected)
CS138A Flow Definition a flow on a graph is a real valued function VxV>R with the following properties capacity constraint: for all u,v in V skew symmetry: for all u,v in V flow conservation: for all u in V\{s,t}
CS138A Flow Definitions the value of a flow is defined as in the maximum flow problem we wish to find the maximum flow from s to t in some graph G=(V,E) non zero net flow from u to v implies (u,v) in E or (v,u) in E
CS138A Flow Multiple sources and sinks introduce super source and super sink with infinite capacity connections to the individuals sources and sinks respectively implicit set summation convention Lemma 1: Let G=(V,E) be a flow network and let f be a flow in G. Then for X subset V
CS138A Example Use implicit set summation to prove by definition by Lemma 1 by flow conservation
CS138A Ford-Fulkerson Method Principles behind differing implementations repeated update through augmenting paths if there is unused capacity left, use it… 1. Ford-Fulkerson-Method(G,s,t) 2. initialize flow to 0 3. while( exists augmenting path ) 4. augment flow f along path 5. return f
CS138A Residual Networks Formalization of remaining flow opportunities given flow network G=(V,E) and flow f define residual capacity the residual flow network is induced by they positive residual capacity G f =(V,E f ) where E f consists of all pairs u,v in V with positive residual flow capacity (note that it can have as many as twice as many edges)
CS138A Properties Residual networks Lemma 2: Let G=(V,E) be a flow network with source s and sink t and f be a flow; let G f be the residual network induced and let f’ be a flow in G f then the flow sum f+f’ is a flow in G with value |f+f’|=|f|+|f’| Augmenting path simple path p in residual network from s to t residual capacity c f (p) is minimum capacity along path p
CS138A Residual Capacity Property Lemma 3: let G=(V,E) be a flow network with flow f and p be an augmenting path in G f. Define then f p is a flow in G f with value |f p |=c f (p) positive
CS138A Residual Capacity Adding an augmenting flow Corollary 4: Let G=(V,E) be a flow network with flow f and p be an augmenting path in G f Let f p be defined as before; define f’=f+f p then f’ is a flow in G with value |f’|=|f|+|f p | greater than |f| immediate from previous two lemmas
CS138A Cuts of Flow Networks What is a cut? a cut(S,T) is a partition of V into S and T with s in S and t in T with net flow f(S,T) and capacity c(S,T) (picture) Lemma 5: let f be a flow in a flow network G with source s and sink t and let (S,T) be a cut of G; then f(S,T)=|f| Corollary 6: the value of any flow f in a flow network G is bounded from above by the capacity of any cut of G
CS138A Cuts in Flow Networks Max-flow min-cut theorem Theorem 7: if f is a flow in a flow network G=(V,E) with source s and sink t, then the following conditions are equivalent: f is a maximum flow in G the residual network G f contains no augmenting paths |f|=c(S,T) for some cut (S,T) of G
CS138A Basic Ford-Fulkerson Iteratively increase flow by residual capacity 1. Ford-Fulkerson(G,s,t) 2. for( (u,v) in E[G] ) 3. f[u,v] = 0; f[v,u] = 0; 4. while( exists path p from s to t in G f ) 5. c f (p) = min{c f (u,v): (u,v) in p} 6. for( (u,v) in E[p] ) 7. f[u,v] = f[u,v]+c f (p); 8. f[v,u] = -f[u,v]
CS138A Ford-Fulkerson Running time: depends on method to pick augmenting path (use BFS) Edmonds-Karp algorithm pick p with BFS looking for the shortest path with unit edge lengths in the residual network; O(VE 2 ) Lemma 8: when Edmunds-Karp is run on G then for all vertices v in V\{s,t} the shortest path distance in the residual network G f increases monotonically with augmentation
CS138A Edmunds-Karp Properties Theorem 9: if the Edmonds-Karp algorithm is run on a flow network G=(V,E) with source s and sink t, then the total number of flow augmentations performed by the algorithm is at most O(VE)