420 likes | 483 Views
Maximum Flow. Maximum Flow A flow network G=(V, E) is a DIRECTED graph where each has a nonnegative capacity. u. Maximum-flow problem
E N D
Maximum Flow A flow network G=(V, E) is a DIRECTED graph where each has a nonnegative capacity u
Maximum-flow problem Given a flow network G with source s and sink t, we wish to find a flow of maximum value from s to t 12 12 v1 v3 11 20 16 15 1 s 10 4 7 t 9 7 4 13 4 v2 v4 8 4 14 11
positive net flow entering a vertex v: Networks with multiple source and sinks: s1 s1 s2 t1 s2 t1 s3 t2 s’ s3 t2 t’ s4 t3 s4 t3 s5 s5
X Y 1 3 • Lemma 1 4 2 X Z Y
Ford-Fulkerson method • Residual networks
Lemma 2 Pf:
Augmenting paths: Given a flow network G=(V,E) and a flow f an augmenting path p is a simple path from s to t in the residual network Gf
Lemma3: • Cor4:
Flow network 12/12 v1 v3 (a) 11/16 15/20 s 10 4 7/7 t 4/9 8/13 4/4 v2 v4 11/14 Residual network 12 v1 v3 (b) 5 5 11 4 15 s 7 t 11 3 5 5 8 4 3 v2 v4 11
Flow network 12/12 v1 v3 (c) 19/20 11/16 s 10 1/4 7/7 t 9 12/13 4/4 v2 v4 11/14 Residual network 12 v1 v3 (d) 5 1 11 19 s 7 t 11 9 3 1 12 4 3 v2 v4 11
12 v1 v3 (a) 16 20 s 10 4 7 t 9 13 4 v2 v4 14 4/12 v1 v3 4/16 20 s 10 4 7 t 4/9 13 4/4 v2 v4 4/14
8 (b) v1 v3 12 4 20 4 4 s 10 7 t 4 5 13 4 10 v2 v4 4 4/12 v1 v3 11/16 7/20 s 4 7/10 7/7 t 4/9 13 4/4 v2 v4 11/14
8 (c) v1 v3 5 4 13 11 4 7 s 3 7 t 11 5 13 4 3 v2 v4 11 12/12 v1 v3 11/16 15/20 s 10 1/4 7/7 t 4/9 8/13 4/4 v2 v4 11/14
12 (d) v1 v3 5 5 11 4 15 s 3 7 t 3 5 5 13 4 3 v2 v4 11 12/12 v1 v3 11/16 19/20 s 10 1/4 7/7 t 9 12/13 4/4 v2 v4 11/14
12 v1 v3 (e) 5 1 11 19 s 7 t 11 9 3 1 12 4 3 v2 v4
The basic Ford-Fulkerson algorithm M M s t 1 M M
Edmonds-karp algorithm Implement the computation of the augmenting path p with a breadth-first search. That is the augmenting path is a shortest path from s to t in the residual network, where each edge has unit distance.
Cuts of flow networks • A cut(S,T) of flow network G=(V,E) is a partition of V into S and T=V-S such that • The net flow across the cut(S,T) is defined to be f(S,T). The capacity of the cut(S,T) is c(S,T) • Eg: S T 12 v1 v3 20 16 s 10 4 7 t 9 13 4 v2 v4 14
Lemma 5 Pf:
Cor6 Pf:
Thm7: Pf:
Lemma 8 Pf:
Thm 9 Pf:
There are at most O(E) pairs of vertices that can have an edge between them in a residual graph, the total number of critical edges during the entire execution of the Edmonds-karp algorithm is O(VE). Each awgmenting path has at least on critical edge, and hence the theorem follows. Each interation of Ford-Fulkerson can be impemented in O(E) time, when the owgmenting Path is found by BFS. Total running time of the Edmonds-karp algorithm is O(CE2). Best to date:
Preflow-push algorithms: • Preflow:a function f: satisfies • (1) skew symmetry • (2) capacity constraints • (3) for all vertices • Excess flow into u: • G=(V,E): a flow network with source s and sink t, and let f be a preflow in G. • Height function:
lemma13: Let G=(V,E) be a flow network, f be a preflow in G, and let h be a Height function on V. for any two vertices , if h(u)>h(v)+1, Then (u,v) is not an edge in the residual graph.
The basic operation PUSH(u,v) can be applied if u is an overflowing vertex, cf(u,v)>0, and h(u)=h(v)+1. • e[u]:the execess flow stored at u. • h[u]:the height of u. • df(u,v):the amount of flow can be pushed from u to v. • Saturating push: if (u,v) becomes saturated(cf(u,v)=0 afterward); otherwise, it is a nonsaturating push. PUSH(u,v) { * Applies when : u is overflowing cf[u,v]>0 and h[u]=h[v]+1. * Action : Push df(u,v)=min(e[u],cf(u,v)) units of flow from u to v. }
LIFT(u) • The basic operation LIFT(w) applies if u is overflowing and if cf(u,v)>0 implies for all v. • When u is lifted, Ef must contain at least one edge that leaves u. • E[u]=f[V,u]>0 there must be at least one vertex v s.t. f[v,u]>0. { * Applies when : u is overflowing and for all implies * Action : Increase the height of u. }
Initialize-Preflow(G,s) { for each vertex do for each vertex do if u=s, if v=s, otherwise for each vertex and do if u=s, otherwise } Generic-Preflow-Push(G) { Initialize-Preflow(G,s) ; While there exists an applicable push or lift op. do select an applicable push or lift op and perform it; }
Lemma14:(An overflowing vertex can be either pushed or lifted) Let G=(V,E) be a flow network with source s and sink t, let f be a preflow, and let h be any height function for f. if u is any overflowing vertex, then either a push or lift op applies to it. • Lemma15: (vertex height never decrease) During the execution of Generic-Perflow-Push on a flow network G=(V,E), for each the height h[u] never decreases. Moreover, whenever a lift operation is applied to a vertex u, its height h[u] increase by at least 1. Proof : For any residual edge (u,v) we have because h is a height function. If a push operation does not apply to u, then for all residual edges (u,v), we must have h(u)<h(v)+1, which implies Thus, a lift operation can be applied to u. Proof : Note that vertex heights change only during lift operations. If u is lifted, then for all v with this implies so the op must increase h[u].
Lemma16: G=(V,E): a flow network S:source t:sink During the execution of Generic-Preflow-Push on G, the attribute h is maintained as a height function. Proof : By induction on the number of basic operations performed. Initially, h is a height function. Claim:if h is a height function, then a operation LIFT(u) leaves h a height function. (1) u v The operation LIFT(u) ensures that (2) w u By lemma15, before the op. LIFT(u) implies h[w]<h[v]+1 afterward. Thus, the operation LIFT(u) leaves h a height function. Consider an operation PUSH(u,v):two possibilities: (1) add the edge (v,u) to Ef:h[v]=h[u]-1, so h remains a height function. (2) Remove (u,v) from Ef: The removal of (u,v) from the residual network removes the corresponding constraint, and h remains a height function.
Lemma17: G=(V,E): flow network ; S:source ; t:sink ; f:preflow in G ; h: height function on V. Thus, there is no path from the source s to the sink t in the residual network Gf. Proof : By contradiction, assume there is a path p=<v0=s,v1,…,vk=t> from s to t in Gf. Assume p is a simple path, then For i=0,1,…,k-1, edge Because h is a height function, for i=0,1,…,k-1. + ) =0 But in a height function. Thus, there is no such path!
Lemma18: (correctness of the generic preflow-push algorithm) If the algorithm Generic-Preflow-Push terminates when run on a flow network G=(V,E) with source s and sink t, then the preflow f it computes is a maximum flow for G. Proof : If the generic algorithm terminates, then each vertex in V-{s,t} must have an excess of 0, by lemma14 and lemma16 and the invariant that f is always a preflow, there are no overflowing vertices. Therefore, f is a flow. Because h is a height function, by lemma17, there is no path form s to t in the residual network Gf. By the max-flow-min-Cut thm, f is a max flow.
Analysis of the preflow-push method: G,s,t,f:as above. • Lemma19: For any overflowing vertex u, there is a simple path from u to s in the residual network Gf. Proof : Let U={ v: there exists a simple path from u to u in Gf } By contradiction, assume Claim: For each pair If f(w,v)>0, then f(v,w)<0, which implies that cf(v,w)=c(v,w)-f(v,w)>0.
Lemma20: G=(V,E), s,t. At any time during the execution of Generic-Preflow-Push on G, we have Proof : Height of s and t never change, s,t never overflow by def. Thus, A vertex is lifted only when if is overflowing. Consider any overflowing vertex By lemma19, there is a simple path from u to s in Gf. Let p=<v0=s,v1,…,vk=t>, and p is simple. For i=0,1,…,k-1, we have
Corollary21: (Bound on lift operations) During the execution of Generic-Preflow-Push on G, the number of lift operations is at most per vertex and at most Proof : Only V-{s,t,} can be lifted. Let . The op. LIFT(u) increases h[u]. The value of h[u] is initially 0. By lemma20, each is lifted at most times. Thus, the total number of lift operations performed is at most