1 / 9

Maximum Flow Algorithms

Maximum Flow Algorithms. Emanuele Altieri CSC252, Fall 2000. What is the maximum amount of material that can be transported from s (source) to t (sink) ?. Town C. 8. Town A. 9. 5. 7. Port ( t ). Mine ( s ). 2. 3. 18. 10. Town B. Town D. 12. Maximum Flow Algorithms.

senwe
Télécharger la présentation

Maximum Flow Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Maximum Flow Algorithms Emanuele Altieri CSC252, Fall 2000

  2. What is the maximum amountof material that can be transportedfrom s (source) to t (sink) ? Town C 8 Town A 9 5 7 Port (t) Mine (s) 2 3 18 10 Town B Town D 12

  3. Maximum Flow Algorithms Given a graph G = (V, E) Ford-Fulkerson method Preflow-Push algorithm Lift-To-Front algorithm T(V, E) = O(E |f*|) T(V, E) = O(V2E) T(V, E) = O(V3) Edmons-Karp algorithm T(V, E) = O(V E2)

  4. Ford-Fulkerson and Edmons-Karp algorithms Flow of a Graph A flow of a graph G = (V, E) is a function f : V V R that satisfies the following properties: Skew Simmetry Flow Conservation Capacity Constraints 4:10 10 u v u v u c (u, v) = 10 c (v, u) = 0 f (u, v) = 4 f (v, u) = –f (u, v) = – 4 In general  u, v  V  f (u, v) = – f (v, u) c (u, v) = 10 f (u, v)  c (u, v) In general  u, v  V  f (u, v)  c (u, v)  u  V – {s, t}  (v  V)f (u, v) = 0 also called net flow into u: f (V, u) = 0 Residual Capacity Given u, vV, the residual capacity cf of (u, v) shows how many flow units can still flow from u to v. cf (u, v) = c (u, v) – f (u, v) 6 u v 6 cf (u, v) = 10 – 4 = 6 4:10 u v u v 4 cf (v, u) = 0 – (– 4) = 4 4 u v Residual Graph 3 5:8 The residual network of a graph G = (V, E) is defined as: s s 5 2:3 5:5 1 G Gf = (V, Ef) Ef = { (u, v)  V  V such that cf (u, v) > 0 } 2 Gf 5 t t 2 2:2

  5. Ford-Fulkerson and Edmons-Karp algorithms Ford-Fulkerson Method for( each edge (u, v)  E [G] ) { f [u, v] = 0 f [v, u] = 0 } while(  p (s  t)  Gf) { cf (p) = min { cf (u, v) where (u, v)  Ef [p] } for( each edge (u, v)  Ef){ f [u, v] = f [u, v] + cf (p) f [v, u] = – f [u, v] } } O(E) s t Time to find p using any traversal: O(E) Max Number of iterations: O(| f * | ) Any path s t is augmented at each iteration T(V, E) = O(E |f*|) Edmons-Karp Algorithm for( each edge (u, v)  E [G] ) { f [u, v] = 0 f [v, u] = 0 } while(  p (s  t)  Gf such that p =  (s, t) ) { cf (p) = min { cf (u, v) where (u, v)  Ef [p] } for( each edge (u, v)  Ef){ f [u, v] = f [u, v] + cf (p) f [v, u] = – f [u, v] } } O(E) s t Time to find  using BFS: O(E) Max Number of iterations: O(VE) The shortes path s t (in length) is augmented at each iteration T(V, E) = O(V E2)

  6. Preflow-Push Algorithm Preflow, instead of flow A preflow of a graph G = (V, E) is a function f : V V R that satisfies the following properties: Capacity Constraints NO Flow Conservation c (u, v) u v u f (u, v)  c (u, v) 15 10 u reservoir Skew Simmetry  u  V – {s} excess flow e(u) = f (V, u)  0  u  V – {s, t} if e(u) > 0 then u is overflowing 5 f (u, v) e(u) = f (V, u) = 5 u v f (v, u) = –f (u, v) Residual Capacity Given u, vV, the residual capacity cf of (u, v) shows how many flow units can still flow from u to v. cf (u, v) = c (u, v) – f (u, v) Height Function Let G = (V, E) be a flow network with source s and sink t, and let f be a preflow in G. A function h : VN is a height function if h(s) = |V| h(t) = 0 h(u)  h(v) + 1,  (u, v)  Ef 5 4 3 2 1 0 s Residual Graph Gf = (V, Ef) Ef = { (u, v)  V  V such that cf (u, v) > 0 and h(u)  h(v) + 1 } t

  7. Preflow-Push Algorithm INITIALIZE-PREFLOW (G, s) LIFT (u) PUSH (u, v) • u  V – { s, t } • Applies when • e(u) > 0 •  v  V (u, v)  Ef h[u]  h[v] • u, v  V • Applies when • e(u) > 0 • cf (u, v) > 0 • h(u) = h(v) + 1 G = (V, E) s  V // Source of the graph for(each vertex u  V [G]) { h[u] = 0 e[u] = 0 } for (each egde (u, v)  E[G]) { f [u, v] = 0 f [v, u] = 0 } h[s] = |V [G] | for(each vertex u  Adj[G]) { f [s, u] = c(s, u) f [s, u] = – c(s, u) e [u] = c (s, u) } h[u] = 1 + min { h[v] : (u, v)  Ef } f = min {e[u], cf (u, v)} f [u, v] = f [u, v] + f f [v, u] = – f [u, v] e[u] = e[u] – f e[v] = e[v] + f GENERIC-PREFLOW-PUSH (G) a a a 0:10 0:10 0:10 15:15 15:15 15:15 INITIALIZE-PREFLOW (G, s) while ( an applicable push or lift) do select an applicable push or lift operation and perform it LIFT(a) PUSH(a, b) 0:8 0:8 8:8 s t s t s t f = 8 10:10 0:20 10:10 0:20 10:10 0:20 b b b 5 4 3 2 1 0 e(u) 5 4 3 2 1 0 e(u) 5 4 3 2 1 0 e(u) s s s 10 10 10 10 15 15 15 10 10 a a 8 20 20 20 8 8 t t t a b b b 15 10 15 10 7 18

  8. Lift-To-Front Algorithm DISCHARGE (u) Vertices List current [u] = head [ N [u] ] while( e[u] > 0 ) v = current [u] if (v == NULL) LIFT (u) current [u] = head [ N [u] ] elseif(cf (u, v) > 0 and h[u] = h[v] + 1) PUSH (u, v) else current [u] = next_neighbor [v] end if end while L = V – { s, t } Neighbor Lists u  L, N[u] = {v  V such that (u, v)  E or (v, u)  E } 0:8 y z 0:10 0:5 14:14 0:7 6 5 4 3 2 1 0 s x t 0:16 12:12 s LIFT-TO-FRONT (G, s) INITIALIZE-PREFLOW (G, s) L = V[G] – { s, t } u = head[L] while( u  NULL) old_height = h[u] DISCHARGE (u) if (h[u] > old_height) move u to the front of list L u = next[u] end while 14 16 12 7 5 x y 8 z 10 t INITIALIZE-PREFLOW (G, s) LIFT (u) PUSH (u, v) • u  V – { s, t } • Applies when • e(u) > 0 • v  V (u, v)  Ef h[u]  h[v] • u, v  V • Applies when • e(u) > 0 • cf (u, v) > 0 • h(u) = h(v) + 1 u, v  V f [u, v] = c(u, v) if u == s – c(v, u) if v==s 0 otherwise h [u] = |V| if u == s 0 otherwise L N N[x] N[y] N[z]

  9. References • Introduction to Algorithms, Thomas Cormen, ch.27, 27.4-5 (Preflow-Flush and Lift-To-Front algorithms. Ford-Fulkerson method and Edmons-Karp algorithm) • Algorithms and Data Structures, Jeffrey Kingston, 12.3 (Ford-Fulkerson method and Edmons-Karp algorithm)

More Related