network flow algorithms
play

Network Flow Algorithms Lecture 14 October 12, 2016 Chandra & - PowerPoint PPT Presentation

CS 473: Algorithms, Fall 2016 Network Flow Algorithms Lecture 14 October 12, 2016 Chandra & Ruta (UIUC) CS473 1 Fall 2016 1 / 42 Part I Algorithm(s) for Maximum Flow Chandra & Ruta (UIUC) CS473 2 Fall 2016 2 / 42 Greedy


  1. CS 473: Algorithms, Fall 2016 Network Flow Algorithms Lecture 14 October 12, 2016 Chandra & Ruta (UIUC) CS473 1 Fall 2016 1 / 42

  2. Part I Algorithm(s) for Maximum Flow Chandra & Ruta (UIUC) CS473 2 Fall 2016 2 / 42

  3. Greedy Approach Begin with f ( e ) = 0 for each edge. u 1 /20 / Find a s - t path P with f ( e ) < c ( e ) 2 1 0 for every edge e ∈ P . s / t 3 Augment flow along this path. 0 3 /20 /10 Repeat augmentation for as long as 4 possible. v Chandra & Ruta (UIUC) CS473 3 Fall 2016 3 / 42

  4. Greedy Approach Begin with f ( e ) = 0 for each edge. u 1 /20 / Find a s - t path P with f ( e ) < c ( e ) 2 1 0 for every edge e ∈ P . s / t 3 Augment flow along this path. 10 0 3 10 /20 /10 Repeat augmentation for as long as 4 10 possible. v Chandra & Ruta (UIUC) CS473 3 Fall 2016 3 / 42

  5. Greedy Approach Begin with f ( e ) = 0 for each edge. u 1 /20 1 0 / Find a s - t path P with f ( e ) < c ( e ) 2 10 1 0 0 1 for every edge e ∈ P . s / t 3 Augment flow along this path. 0 3 10 /20 /10 Repeat augmentation for as long as 4 10 possible. v Chandra & Ruta (UIUC) CS473 3 Fall 2016 3 / 42

  6. Greedy Approach Begin with f ( e ) = 0 for each edge. u 1 /20 1 0 / Find a s - t path P with f ( e ) < c ( e ) 2 20 1 0 1 for every edge e ∈ P . 0 s / t 10 3 Augment flow along this path. 0 3 10 /20 /10 Repeat augmentation for as long as 4 20 possible. v Chandra & Ruta (UIUC) CS473 3 Fall 2016 3 / 42

  7. Greedy Approach: Issues Issues = What is this nonsense? u Begin with f ( e ) = 0 for each edge /20 1 / 1 0 Find a s - t path P with f ( e ) < c ( e ) 2 for every edge e ∈ P s / t 3 0 Augment flow along this path 3 /20 /10 Repeat augmentation for as long as 4 v possible. Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 42

  8. Greedy Approach: Issues Issues = What is this nonsense? u Begin with f ( e ) = 0 for each edge /20 1 / 1 20 0 Find a s - t path P with f ( e ) < c ( e ) 2 2 0 for every edge e ∈ P s / 20 t 3 0 Augment flow along this path 3 /20 /10 20 Repeat augmentation for as long as 4 v possible. Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 42

  9. Greedy Approach: Issues Issues = What is this nonsense? u Begin with f ( e ) = 0 for each edge /20 /20 1 / / 1 1 20 0 0 Find a s - t path P with f ( e ) < c ( e ) 2 2 0 for every edge e ∈ P s / / t 3 3 0 0 Augment flow along this path 3 /20 /20 /10 /10 20 Repeat augmentation for as long as 4 v possible. Greedy can get stuck in sub-optimal flow! Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 42

  10. Greedy Approach: Issues Issues = What is this nonsense? Begin with f ( e ) = 0 for each edge u 1 /20 /20 / / Find a s - t path P with f ( e ) < c ( e ) 2 20 1 1 0 0 2 2 for every edge e ∈ P 0 0 s / / t 3 3 Augment flow along this path 10 0 0 3 10 /20 /20 /10 /10 Repeat augmentation for as long as 4 20 possible. v Greedy can get stuck in sub-optimal flow! Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 42

  11. Greedy Approach: Issues Issues = What is this nonsense? Begin with f ( e ) = 0 for each edge u 1 /20 / Find a s - t path P with f ( e ) < c ( e ) 2 20 1 � �� � 2 0 0 =10 − for every edge e ∈ P 1 0 s / t 3 Augment flow along this path 10 0 3 10 /20 /10 Repeat augmentation for as long as 4 20 possible. v Greedy can get stuck in sub-optimal flow! Need to “push-back” flow along edge ( u , v ) . Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 42

  12. Greedy Approach: Issues Issues = What is this nonsense? Begin with f ( e ) = 0 for each edge u 1 /20 1 0 / Find a s - t path P with f ( e ) < c ( e ) 2 20 1 0 1 for every edge e ∈ P 0 s / t 3 Augment flow along this path 10 0 3 10 /20 /10 Repeat augmentation for as long as 4 20 possible. v Greedy can get stuck in sub-optimal flow! Need to “push-back” flow along edge ( u , v ) . Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 42

  13. Residual Graph The “leftover” graph Definition For a network G = ( V , E ) and flow f , the residual graph G f = ( V ′ , E ′ ) of G with respect to f is V ′ = V , 1 Forward Edges : For each edge e ∈ E with f ( e ) < c ( e ) , we 2 add e ∈ E ′ with capacity c ( e ) − f ( e ) . Backward Edges : For each edge e = ( u , v ) ∈ E with 3 f ( e ) > 0 , we add ( v , u ) ∈ E ′ with capacity f ( e ) . Chandra & Ruta (UIUC) CS473 5 Fall 2016 5 / 42

  14. Residual Graph Example u u /20 /20 /20 / / 20 1 1 / 0 0 1 0 2 0 0 1 s / / t / / 3 3 s t 2 0 0 0 /20 /20 /10 /10 /20 /10 20 v v Figure: Flow on edges is indicated in Figure: Residual Graph red Chandra & Ruta (UIUC) CS473 6 Fall 2016 6 / 42

  15. Residual graph has... Given a network with n vertices and m edges, and a valid flow f in it, the residual network G f , has (A) m edges. (B) ≤ 2 m edges. (C) ≤ 2 m + n edges. (D) 4 m + 2 n edges. (E) nm edges. (F) just the right number of edges - not too many, not too few. Chandra & Ruta (UIUC) CS473 7 Fall 2016 7 / 42

  16. Residual Graph Property Observation: Residual graph captures the “residual” problem exactly. Chandra & Ruta (UIUC) CS473 8 Fall 2016 8 / 42

  17. Residual Graph Property Observation: Residual graph captures the “residual” problem exactly. Lemma Let f be a flow in G and G f be the residual graph. If f ′ is a flow in G f then f + f ′ is a flow in G of value v ( f ) + v ( f ′ ) . Chandra & Ruta (UIUC) CS473 8 Fall 2016 8 / 42

  18. Residual Graph Property Observation: Residual graph captures the “residual” problem exactly. Lemma Let f be a flow in G and G f be the residual graph. If f ′ is a flow in G f then f + f ′ is a flow in G of value v ( f ) + v ( f ′ ) . Lemma Let f and f ′ be two flows in G with v ( f ′ ) ≥ v ( f ) . Then there is a flow f ′′ of value v ( f ′ ) − v ( f ) in G f . Chandra & Ruta (UIUC) CS473 8 Fall 2016 8 / 42

  19. Residual Graph Property Observation: Residual graph captures the “residual” problem exactly. Lemma Let f be a flow in G and G f be the residual graph. If f ′ is a flow in G f then f + f ′ is a flow in G of value v ( f ) + v ( f ′ ) . Lemma Let f and f ′ be two flows in G with v ( f ′ ) ≥ v ( f ) . Then there is a flow f ′′ of value v ( f ′ ) − v ( f ) in G f . Definition of + and - for flows is intuitive and the above lemmas are easy in some sense but a bit messy to formally prove. Chandra & Ruta (UIUC) CS473 8 Fall 2016 8 / 42

  20. Residual Graph Property: Implication Recursive algorithm for finding a maximum flow: MaxFlow ( G , s , t ): if the flow from s to t is 0 then return 0 Find any flow f with v ( f ) > 0 in G Recursively compute a maximum flow f ′ in G f Output the flow f + f ′ Chandra & Ruta (UIUC) CS473 9 Fall 2016 9 / 42

  21. Residual Graph Property: Implication Recursive algorithm for finding a maximum flow: MaxFlow ( G , s , t ): if the flow from s to t is 0 then return 0 Find any flow f with v ( f ) > 0 in G Recursively compute a maximum flow f ′ in G f Output the flow f + f ′ Iterative algorithm for finding a maximum flow: MaxFlow ( G , s , t ): Start with flow f that is 0 on all edges while there is a flow f ′ in G f with v ( f ′ ) > 0 do f = f + f ′ Update G f Output f Chandra & Ruta (UIUC) CS473 9 Fall 2016 9 / 42

  22. Ford-Fulkerson Algorithm algFordFulkerson for every edge e , f ( e ) = 0 G f is residual graph of G with respect to f while G f has a simple s - t path do let P be simple s - t path in G f f = augment( f , P ) Construct new residual graph G f . Chandra & Ruta (UIUC) CS473 10 Fall 2016 10 / 42

  23. Ford-Fulkerson Algorithm algFordFulkerson for every edge e , f ( e ) = 0 G f is residual graph of G with respect to f while G f has a simple s - t path do let P be simple s - t path in G f f = augment( f , P ) Construct new residual graph G f . augment ( f , P ) let b be bottleneck capacity, i.e., min capacity of edges in P (in G f ) for each edge ( u , v ) in P do if e = ( u , v ) is a forward edge then f ( e ) = f ( e ) + b else (* ( u , v ) is a backward edge *) let e = ( v , u ) (* ( v , u ) is in G *) f ( e ) = f ( e ) − b return f Chandra & Ruta (UIUC) CS473 10 Fall 2016 10 / 42

  24. Example u u 10 30 10 s s t t 15 20 v v u u 10 30 10 s t s t 15 20 v v Chandra & Ruta (UIUC) CS473 11 Fall 2016 11 / 42

  25. Example continued u u 10 30 10 s s t t 15 20 v v u u 10 30 10 s t s t 15 20 v v Chandra & Ruta (UIUC) CS473 12 Fall 2016 12 / 42

  26. Example continued u u 10 30 10 s s t t 15 20 v v u u 10 30 10 s t s t 15 20 v v Chandra & Ruta (UIUC) CS473 13 Fall 2016 13 / 42

  27. Example continued u u 10 30 10 s s t t 15 20 v v u u 10 30 10 s t s t 15 20 v v Chandra & Ruta (UIUC) CS473 14 Fall 2016 14 / 42

  28. Properties about Augmentation: Flow Lemma If f is a flow and P is a simple s - t path in G f , then f ′ = augment ( f , P ) is also a flow. Chandra & Ruta (UIUC) CS473 15 Fall 2016 15 / 42

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