today
play

Today Flow review Augmenting paths Ford-Fulkerson Algorithm Intro - PowerPoint PPT Presentation

Today Flow review Augmenting paths Ford-Fulkerson Algorithm Intro to cuts (reason: prove correctness) Flow Networks s = source, t = sink. c(e) = capacity of edge e Capacity condition: 0 f(e) c(e) Conservation condition: for v V


  1. Today Flow review Augmenting paths Ford-Fulkerson Algorithm Intro to cuts (reason: prove correctness)

  2. Flow Networks s = source, t = sink. c(e) = capacity of edge e Capacity condition: 0 ≤ f(e) ≤ c(e) Conservation condition: for v ∈ V – {s, t}: � ∑ f(e) = ∑ f(e) e into v e out of v 0 5 2 9 0 0 0 4 10 15 15 10 flow = 4 4 0 0 0 t sink s source 3 5 8 6 10 0 4 15 4 0 0 6 10 15 4 4 7 30 0

  3. Flows The value of a flow f is: v(f) = ∑ f(e) e out of s 0 value = 4 5 2 9 0 0 0 4 10 15 15 10 flow = 4 4 0 0 0 t sink s source 3 5 8 6 10 0 4 15 4 0 0 6 10 15 4 4 7 30 0

  4. Flows The value of a flow f is: v(f) = ∑ f(e) e out of s 9 value = 24 5 2 9 0 9 1 0 10 15 15 10 flow = 10 4 4 6 6 t sink s source 3 5 8 6 10 0 9 15 4 10 1 6 10 15 0 4 7 30 10

  5. Maximum Flow Problem Find s-t flow of maximum value. 9 value = 28 5 2 9 0 9 0 1 10 15 15 10 flow = 10 4 5 8 9 t sink s source 3 5 8 6 10 0 10 15 4 13 3 6 10 15 0 4 7 30 13

  6. Towards a Max-Flow Algorithm Key idea: repeatedly choose paths and “augment” the amount of flow on those paths as much as possible until capacities are met

  7. Towards a Max Flow Algorithm Problem: possible to get stuck at a flow that is not maximum, no more paths with excess capacity 1 × 20 0 0 20 10 × s t 30 0 20 10 20 × × Flow value = 0 20 0 0 20 2

  8. Residual Graph Original edge: e = (u, v) ∈ E. u 17 v Flow f(e), capacity c(e). 6 Create two residual edges residual Forward edge capacity e = (u, v) with capacity c(e) - f(e) u v 11 Backward/reverse edge 6 e ’ = (v, u) with capacity f(e) Residual graph: G f = (V , E f ). E f = edges with positive residual capacity E f = {e : f(e) < c(e)} ∪ {e ’ : f(e) > 0}

  9. Augmenting Path Definition: an s-t path P in G f is an augmenting path Idea: use an augmenting path to augment flow in G Increase flow on forward edges Decrease flow on backward edges Definition: let bottleneck(P, f) be the minimum residual capacity (i.e., capacity in G f ) of any edge in P Example on board

  10. Augmenting Path Use path P in G f to to update flow f Augment(f, P) { / / edge on P with least residual capacity b = bottleneck(P, f) foreach e = (u,v) ∈ P { if e is a forward edge f(e) = f(e) + b / / forward edge: increase flow else let e’ = (v, u) f(e’) = f(e’) - b / / backward edge: decrease flow } return f }

  11. Augmenting Path Claim: Let f be a flow and let f’ = Augment(f, P). Then f’ is a flow. Proof idea: verify capacity and conservation conditions 1) Capacity: by design of residual graph 2) Conservation: check that net change at each node is zero Proof sketch on board

  12. Ford-Fulkerson Algorithm Repeat: find an augmenting path, and augment! Ford-Fulkerson(G, s, t) { foreach e ∈ E f(e) = 0 // initially, no flow G f = copy of G // residual graph = original graph while (there exists an s-t path P in G f ) { f = Augment(f, P) // change the flow update G f // build a new residual graph } return f }

  13. Example 0 4 2 4 G: 0 0 0 6 0 8 10 10 2 0 0 0 0 10 s 3 9 5 10 t Flow value = 0

  14. Example 0 4 2 4 × × G 8 0 0 8 0 6 0 8 10 10 2 0 × 0 8 0 0 10 s 3 9 5 10 t × Flow value = 0 8 4 2 4 G f 6 8 10 10 2 10 s 3 9 5 10 t

  15. Example 0 4 2 4 × G 10 8 0 8 × 6 0 8 10 10 2 0 2 × 2 × 0 10 8 0 10 s 3 9 5 10 t × Flow value = 8 10 4 2 4 G f 8 6 8 10 2 2 10 s 3 9 5 2 t 8

  16. Example 0 4 2 4 × G 8 0 10 6 × 6 0 8 10 10 2 2 6 × × 0 10 6 2 8 10 s 3 9 5 10 t × Flow value = 10 16 4 2 4 G f 10 6 8 10 2 10 s 3 7 5 t 2 10

  17. Example × 2 0 4 2 4 × 8 G 8 6 10 × 6 6 8 10 10 2 2 0 × 8 6 8 10 10 s 3 9 5 10 t × Flow value = 16 18 4 2 4 Gf 10 6 6 8 4 2 4 s 3 1 5 t 6 8 10

  18. Example × 3 2 4 2 4 × 7 × 9 G 8 8 10 6 6 8 10 10 0 2 × 9 × 9 8 8 10 10 s 3 9 5 10 t × Flow value = 18 2 19 2 2 4 G f 10 8 6 8 2 2 2 s 3 1 5 t 8 8 10

  19. Example 3 4 2 4 G 10 7 9 6 6 8 10 10 0 2 9 9 10 10 s 3 9 5 10 t max flow = 19 3 1 2 4 G f 10 9 6 7 1 2 1 1 s 3 5 t 9 9 10

  20. Termination Assumption. All capacities are positive integers. Invariant. Every flow value f(e) and every residual capacity c f (e) remains an integer throughout the algorithm. Theorem. Let OPT = value of max flow. The algorithm terminates in at most OPT iterations, with OPT ≤ C, the total capacity of the edges leaving the source. Proof?

  21. Running Time? There are at most C augment operations. How long does it take for each? O(m+n) Find a residual path Compute bottleneck capacity O(m) Update flow O(m) Update residual graph O(m) Total running time: O(C(m+n))

  22. Cuts An s-t cut is a partition (A, B) of V with s ∈ A and t ∈ B. The capacity of a cut (A, B) is c(A,B) = Σ c(e) e out of A B 5 2 9 A 10 15 15 10 4 t sink s source 3 5 8 6 10 15 4 6 10 15 capacity of cut = 30 4 7 30

  23. Cuts capacity of cut = 9 + 15 + 8 + 30 = 62 (Capacity is sum of weights on edges leaving A.) B A 5 2 9 10 15 15 10 4 t sink s source 3 5 8 6 10 15 4 6 10 15 4 7 30

  24. Flows and Cuts Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then, the net flow sent across the cut is equal to the amount leaving s. ∑ f(e) - ∑ f(e) = v(f) e out of a e into a B 9 value = 24 5 2 9 A 0 9 1 0 10 10 15 15 10 4 4 6 6 t sink s source 3 5 8 6 10 0 9 15 4 10 1 6 10 15 0 4 7 30 10

  25. Flows and Cuts Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then, the net flow sent across the cut is equal to the amount leaving s. ∑ f(e) - ∑ f(e) = v(f) e out of a e into a 9 B value = 24 A 5 2 9 0 9 1 0 10 10 15 15 10 4 4 6 6 t sink s source 3 5 8 6 10 0 9 15 4 10 1 6 10 15 0 4 7 30 10

  26. Flows and Cuts Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then, the net flow sent across the cut is equal to the amount leaving s. ∑ f(e) - ∑ f(e) = v(f) e out of a e into a 9 value = 24 5 2 9 A 0 9 1 0 10 10 15 15 10 4 B 4 6 6 t sink s source 3 5 8 6 10 0 9 15 4 10 1 6 10 15 0 4 7 30 10

  27. Flows and Cuts Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then ∑ f(e) - ∑ f(e) = v(f). e out of A e into A Proof: v(f) = ∑ f(e) by definition e out of s by flow conservation, all terms = ∑ ( ∑ f(e) - ∑ f(e) ) except v = s are 0 v ∈ A e out of v e into v if both endpoints of e are in A, = ∑ f(e) - ∑ f(e) there will be canceling terms e out of A e into A for that edge

  28. Max-Flow Min-Cut There is a deep connection between flows and cuts in networks Next time, we will prove that Ford-Fulkerson is correct by proving the Max-Flow Min-Cut Theorem

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend