network flow
play

Network Flow Lecturer: Shi Li Department of Computer Science and - PowerPoint PPT Presentation

CSE 632: Analysis of Algorithms II: Combinatorial Optimization and Linear Programming (Fall 2020) Network Flow Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Outline Network Flow 1 Ford-Fulkerson


  1. CSE 632: Analysis of Algorithms II: Combinatorial Optimization and Linear Programming (Fall 2020) Network Flow Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo

  2. Outline Network Flow 1 Ford-Fulkerson Method 2 Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm Applications of Network-Flow 3 Single Commodity Flow with Multiple Sources and Sinks s - t Edge-Disjoint Paths Problem Bipartite Matching Problem 2/77

  3. Flow Network Abstraction of fluid flowing through edges Digraph G = ( V, E ) with source s ∈ V and sink t ∈ V No edges enter s No edges leave t Edge capacity c ( e ) ∈ R > 0 for every e ∈ E 12 a c 20 16 s t 7 4 9 13 4 b d 14 3/77

  4. Def. An s - t flow is a function f : E → R such that for every e ∈ E : 0 ≤ f ( e ) ≤ c ( e ) (capacity conditions) for every v ∈ V \ { s, t } : � � f ( e ) = f ( e ) . (conservation conditions) e into v e out of v The value of a flow f is � val ( f ) = f ( e ) . e out of s Maximum Flow Problem Input: directed network G = ( V, E ) , capacity function c : E → R > 0 , source s ∈ V and sink t ∈ V Output: an s - t flow f in G with the maximum val ( f ) 4/77

  5. Maximum Flow Problem: Example 12/12 a c 19/20 12/16 0/4 7/7 s t 0/9 11/13 4/4 b d 11/14 5/77

  6. Outline Network Flow 1 Ford-Fulkerson Method 2 Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm Applications of Network-Flow 3 Single Commodity Flow with Multiple Sources and Sinks s - t Edge-Disjoint Paths Problem Bipartite Matching Problem 6/77

  7. Greedy Algorithm Start with empty flow: f ( e ) = 0 for every e ∈ E Define the residual capacity of e to be c ( e ) − f ( e ) Find an augmenting path: a path from s to t , where all edges have positive residual capacity Augment flow along the path as much as possible Repeat until we got stuck 7/77

  8. Greedy Algorithm: Example 12/12 a c 19/20 12/16 0/4 7/7 s t 0/9 11/13 4/4 b d 11/14 8/77

  9. Greedy Algorithm Does Not Always Give a Optimum Solution a 0/1 0/1 1/1 1/1 s t 0/1 0/1 1/1 b 9/77

  10. Fix the Issue: Allowing “Undo” Flow Sent a 1/1 1/1 0/1 s t 1/1 1/1 b 10/77

  11. Assumption ( u, v ) and ( v, u ) can not both be in E Def. For a s - t flow f , the residual graph G f of G = ( V, E ) w.r.t f contains: the vertex set V , for every e = ( u, v ) ∈ E with f ( e ) < c ( e ) , a forward edge e = ( u, v ) , with residual capacity c f ( e ) = c ( e ) − f ( e ) , for every e = ( u, v ) ∈ E with f ( e ) > 0 , a backward edge e ′ = ( v, u ) , with residual capacity c f ( e ′ ) = f ( e ) . a a 0/1 0/1 1/1 1 1 1/1 s t s t 1 0/1 0/1 1 1 1/1 b b Residual Graph G f Original graph G and f 11/77

  12. Residual Graph: One More Example G f G s s 4/16 0 / 12 13 1 3 4 0/4 4 a b a b 9 / 4/12 4/14 4 5 0 4 8 4 4 1 0/7 7 c d c d 0 4/4 / 20 4 2 0 t t 12/77

  13. Agumenting Path Augmenting the flow along a path P from s to t in G f Augment ( P ) 1: b ← min e ∈ P c f ( e ) 2: for every ( u, v ) ∈ P do if ( u, v ) is a forward edge then 3: f ( u, v ) ← f ( u, v ) + b 4: ⊲ ( u, v ) is a backward edge else 5: f ( v, u ) ← f ( v, u ) − b 6: 7: return f 13/77

  14. Example for Augmenting Along a Path a a 0/1 0/1 1/1 1 1 1 s t s t / 1 1 0/1 0/1 1/1 1 1 b b 14/77

  15. Ford-Fulkerson’s Method Ford-Fulkerson ( G, s, t, c ) 1: let f ( e ) ← 0 for every e in G 2: while there is a path from s to t in G f do let P be any simple path from s to t in G f 3: f ← augment ( f, P ) 4: 5: return f 15/77

  16. Ford-Fulkerson: Example G f G s s 1 8/16 1 / 2 8 1 3 8 11 0/4 4 a b a b 9 / 8/12 11/14 0 9 1 4 8 3 1 7/7 7 c d c d 1 15 5 4/4 / 4 2 5 0 t t 16/77

  17. Outline Network Flow 1 Ford-Fulkerson Method 2 Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm Applications of Network-Flow 3 Single Commodity Flow with Multiple Sources and Sinks s - t Edge-Disjoint Paths Problem Bipartite Matching Problem 17/77

  18. Correctness of Ford-Fulkerson’s Method The procedure augment ( f, P ) maintains the two conditions: 1 for every e ∈ E : 0 ≤ f ( e ) ≤ c ( e ) (capacity conditions) for every v ∈ V \ { s, t } : � � f ( e ) = f ( e ) . (conservation conditions) e into v e out of v When Ford-Fulkerson’s Method terminates, val ( f ) is 2 maximized Ford-Fulkerson’s Method will terminate 3 18/77

  19. Correctness of Ford-Fulkerson’s Method The procedure augment ( f, P ) maintains the two conditions: 1 for every e ∈ E : 0 ≤ f ( e ) ≤ c ( e ) (capacity conditions) for every v ∈ V \ { s, t } : � � f ( e ) = f ( e ) . (conservation conditions) e into v e out of v When Ford-Fulkerson’s Method terminates, val ( f ) is 2 maximized Ford-Fulkerson’s Method will terminate 3 19/77

  20. for every e ∈ E : 0 ≤ f ( e ) ≤ c ( e ) (capacity conditions) for every v ∈ V \ { s, t } : � � f ( e ) = f ( e ) . (conservation conditions) e into v e out of v + b − b + b + b − b t s for an edge e correspondent to a forward edge : b ≤ c ( e ) − f ( e ) = ⇒ f ( e ) + b ≤ c ( e ) for an edge e correspondent to a backward edge : b ≤ f ( e ) = ⇒ f ( e ) − b ≥ 0 20/77

  21. Correctness of Ford-Fulkerson’s Method The procedure augment ( f, P ) maintains the two conditions: 1 for every e ∈ E : 0 ≤ f ( e ) ≤ c ( e ) (capacity conditions) for every v ∈ V \ { s, t } : � � f ( e ) = f ( e ) . (conservation conditions) e into v e out of v When Ford-Fulkerson’s Method terminates, val ( f ) is 2 maximized Ford-Fulkerson’s Method will terminate 3 21/77

  22. Def. An s - t cut of G = ( V, E ) is a pair ( S ⊆ V, T = V \ S ) such that s ∈ S and t ∈ T . Def. The cut value of an s - t cut is � c ( S, T ) := c ( e ) . e =( u,v ) ∈ E : u ∈ S,v ∈ T Def. Given an s - t flow f and an s - t cut ( S, T ) , the net flow sent from S to T is � � f ( e ) − f ( S, T ) := f ( e ) . e =( u,v ) ∈ E : u ∈ S,v ∈ T e =( u,v ) ∈ E : u ∈ T,v ∈ S 22/77

  23. T S 9/14 b d 4/4 3 c ( S, T ) = 14 + 12 = 26 1 / 5 4 7 4 G s / / t / 0 9 5 6/16 f ( S, T ) = 9 + 6 − 4 = 11 7/20 a c 6/12 Obs. f ( S, T ) ≤ c ( S, T ) s - t cut ( S, T ) . Obs. f ( S, T ) = val ( f ) for any s - t flow f and any s - t cut ( S, T ) . Coro. val ( f ) ≤ s - t cut ( S,T ) c ( S, T ) for every s - t flow f. min 23/77

  24. Coro. val ( f ) ≤ s - t cut ( S,T ) c ( S, T ) for every s - t flow f. min We will prove Main Lemma The flow f found by the Ford-Fulkerson’s Method satisfies val ( f ) = c ( S, T ) for some s - t cut ( S, T ) . Corollary and Main Lemma implies Maximum Flow Minimum Cut Theorem sup val ( f ) = s - t cut ( S,T ) c ( S, T ) . min s - t flow f 24/77

  25. Maximum Flow Minimum Cut Theorem sup val ( f ) = s - t cut ( S,T ) c ( S, T ) . min s - t flow f 12/12 a c 19/20 12/16 0/4 7 s t 0/9 / 7 11/13 4/4 b d 11/14 25/77

  26. Main Lemma The flow f found by the Ford-Fulkerson’s Method satisfies val ( f ) = c ( S, T ) for some s - t cut ( S, T ) . Proof of Main Lemma. When algorithm terminates, no path from s to t in G f , What can we say about G f ? There is a s - t cut ( S, T ) , such that there are no edges from S to T For every e = ( u, v ) ∈ E, u ∈ S, v ∈ T , we have f ( e ) = c ( e ) For every e = ( u, v ) ∈ E, u ∈ T, v ∈ S , we have f ( e ) = 0 � Thus, val ( f ) = f ( S, T ) = f ( e ) − e =( u,v ) ∈ E,u ∈ S,v ∈ T � � f ( e ) = c ( e ) = c ( S, T ) . e =( u,v ) ∈ E,u ∈ T,v ∈ S e =( u,v ) ∈ E,u ∈ S,v ∈ T 26/77

  27. Correctness of Ford-Fulkerson’s Method The procedure augment ( f, P ) maintains the two conditions: 1 for every e ∈ E : 0 ≤ f ( e ) ≤ c ( e ) (capacity conditions) for every v ∈ V \ { s, t } : � � f ( e ) = f ( e ) . (conservation conditions) e into v e out of v When Ford-Fulkerson’s Method terminates, val ( f ) is 2 maximized Ford-Fulkerson’s Method will terminate 3 27/77

  28. Ford-Fulkerson’s Method will Terminate Intuition: In every iteration, we increase the flow value by some amount There is a maximum flow value So the algorithm will finally reach the maximum value However, the algorithm may not terminate if some capacities are irrational numbers. (“Pathological cases”) 28/77

  29. Lemma Ford-Fulkerson’s Method will terminate if all capacities are integers. Proof. The maximum flow value is finite (not ∞ ). In every iteration, we increase the flow value by at least 1. So the algorithm will terminate. Integers can be replaced by rational numbers. 29/77

  30. Correctness of Ford-Fulkerson’s Method The procedure augment ( f, P ) maintains the two conditions: 1 for every e ∈ E : 0 ≤ f ( e ) ≤ c ( e ) (capacity conditions) for every v ∈ V \ { s, t } : � � f ( e ) = f ( e ) . (conservation conditions) e into v e out of v When Ford-Fulkerson’s Method terminates, val ( f ) is 2 maximized Ford-Fulkerson’s Method will terminate 3 30/77

  31. Outline Network Flow 1 Ford-Fulkerson Method 2 Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm Applications of Network-Flow 3 Single Commodity Flow with Multiple Sources and Sinks s - t Edge-Disjoint Paths Problem Bipartite Matching Problem 31/77

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