160 likes | 319 Views
Network Flows. Peter Schröder. 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
E N D
Network Flows Peter Schröder
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)
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}
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
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
Example • Use implicit set summation to prove by definition by Lemma 1 by Lemma 1 by Lemma 1 by flow conservation
Ford-Fulkerson Method • Principles behind differing implementations • repeated update through augmenting paths • if there is unused capacity left, use it… Ford-Fulkerson-Method(G,s,t) initialize flow to 0 while( exists augmenting path ) augment flow f along path return f
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 Gf=(V,Ef) where Ef 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)
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 Gf be the residual network induced and let f’ be a flow in Gf 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 cf(p) is minimum capacity along path p
Residual Capacity • Property • Lemma 3: let G=(V,E) be a flow network with flow f and p be an augmenting path in Gf. Define then fp is a flow in Gf with value |fp|=cf(p) positive
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 Gf Let fp be defined as before; define f’=f+fp then f’ is a flow in G with value |f’|=|f|+|fp| greater than |f| • immediate from previous two lemmas
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
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 Gf contains no augmenting paths • |f|=c(S,T) for some cut (S,T) of G
Basic Ford-Fulkerson • Iteratively increase flow by residual capacity Ford-Fulkerson(G,s,t) for( (u,v) in E[G] ) f[u,v] = 0; f[v,u] = 0; while( exists path p from s to t in Gf ) cf(p) = min{cf(u,v): (u,v) in p} for( (u,v) in E[p] ) f[u,v] = f[u,v]+cf(p); f[v,u] = -f[u,v]
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(VE2) • 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 Gf increases monotonically with augmentation
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)