1 / 54

CSE 780: Design and Analysis of Algorithms

CSE 780: Design and Analysis of Algorithms. Lecture 17: Max Flow Definitions. Flow network. Directed graph G = (V, E) with non-negative edge weights c : E -> R c (u, v): capacity of an edge (u, v)  E c ( u,v ) = 0 if ( u,v )  E If then s : source of the network

galena
Download Presentation

CSE 780: Design and Analysis of 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. CSE 780: Design and Analysis of Algorithms Lecture 17: Max Flow Definitions CSE 2331/5331

  2. Flow network • Directed graph G = (V, E) with non-negative edge weights c : E -> R • c (u, v):capacity of an edge (u, v)  E • c (u,v) = 0 if (u,v) E • If then • s: source of the network • t: sink of the network We can still handle it if this is not satisfied. CSE 2331/5331

  3. Flow • Aflow is a function f:V  V  Rs.t., • Capacity constraint: • For all u, v V, 0 ≤f(u,v) ≤ c(u,v) • Flow conservation constraint: • For all u V - {s,t}, That is, flow in = flow out. CSE 2331/5331

  4. Value of Flow • Given a flow f, the value of f is • : i.e., total flow out of the source CSE 2331/5331

  5. Value of Flow • Lemma: • That is, total flow out of source s = total flow in sink t. CSE 2331/5331

  6. Max Flow Problem • Max flow problem: • Given a flow network G, find over all flows f in G. Max flow has value 23. CSE 2331/5331

  7. Max Flow Problem • Given a flow network G, compute the max flow in G. CSE 2331/5331

  8. Example Are we done? CSE 2331/5331

  9. Example Max flow value: 23. CSE 2331/5331

  10. Second Example CSE 2331/5331

  11. Second Example Are we done ? CSE 2331/5331

  12. Second Example We have another augmenting path! CSE 2331/5331

  13. Max Flow for Second Example Max flow value = 14. How do we know it is not possible to further improve? CSE 2331/5331

  14. Residual Network • Given a flow f in the network • Residual network is another directed graph defined on the same nodes with capacity on edges defined as: • For an edge , its residual capacity is: • consists of all edges with non-zero residual capacity CSE 2331/5331

  15. Residual Capacity • Residual capacity is always positive, which follows from : • capacity constraints of the flow , and • in input network , edges and cannot both exists. CSE 2331/5331

  16. Example CSE 2331/5331

  17. Augmenting Path • Any directed path from source to sink in the residual network is called an augmenting path. CSE 2331/5331

  18. Augmenting-Path Lemma: • Given an augmenting path , let be the smallest residual capacity along the path. Then there is a new flow with value as defined below: Intuitively, think of a flow on the path with value , CSE 2331/5331

  19. Example New flow CSE 2331/5331

  20. More Examples • What is the residual network? • What are some augmenting paths? CSE 2331/5331

  21. More Examples • What is the residual network? • What are some augmenting paths? Can we further improve this flow? CSE 2331/5331

  22. Max-Flow-Residual Theorem • Max-Flow-Residual Theorem • A flow f is a max-flow if and only if its residual network admits no augmenting path. • Proof: • One direction easy: If f is max flow, then there is no augmenting path in the residual network. • The other direction will be handled later. Suggests an algorithm to compute Max-flow. CSE 2331/5331

  23. Is this flow Max-flow? New flow CSE 2331/5331

  24. Ford-Fulkerson Max Flow Alg. CSE 2331/5331

  25. Ford-Fulkerson Alg. (More detailed) CSE 2331/5331

  26. Example CSE 2331/5331

  27. Time Complexity Analysis of Ford-Fulkerson Max Flow Algorithm. CSE 2331/5331

  28. CSE 2331/5331

  29. Special Case • Consider only the case where all capacities are integers! • Integer-Flow Lemma: If all capacities of the flow network are integers, then FFMaxFlow() algorithm increases the flow by a positive integer at each iteration. CSE 2331/5331

  30. Time Complexity for Integers Case • Time Complexity: • Let be the number of edges in an input flow network and let be the max-flow. If all capacities are integers, then FFMaxFlow() algorithm runs in time. • Note: • Time complexity depends on the output size. CSE 2331/5331

  31. x 1000 1000 1 t s 1000 1000 y Remark • Performance depending on the augmenting paths we choose. • There is one strategy that makes sure we choose good augmenting path (Edmonds-Karp Algorithm), but we will not cover it in this class. CSE 2331/5331

  32. Multi-sources and multi-sinks flow networks CSE 2331/5331

  33. Sources: • Sinks: • Value of a flow f: CSE 2331/5331

  34. Multi-Source/Sink Max Flow Problem • Given a flow network with multiple sources and sinks, find the flow with maximum value. • Reduce to single source/sink max-flow problem! • By adding an extra super-source and super-sink. CSE 2331/5331

  35. Example CSE 2331/5331

  36. Multi-Source/Sink Max-Flow CSE 2331/5331

  37. Max-Flow Min-Cut CSE 2331/5331

  38. Cuts • A cutof a flow network G = (V, E) • is a partition of V into S and , such that and • The capacity of cut (S, T) is Capacity = 25 Capacity = 36 Capacity = 28 CSE 2331/5331

  39. Min-Cut • A minimum-cut is a cut whose capacity is minimum over all cuts Min-cut: Capacity = 23 CSE 2331/5331

  40. Net Flow • The net flow across cut (S, T) is • That is, flow from S to T minus flow from T to S. Net flow = 19 Net flow = 19 CSE 2331/5331

  41. Net Flow Property I • Net-Flow Lemma Given a flow in a network the net-flow is the same for any cut , and . • Proof intuition: • Intuitively, due to flow conservation property. CSE 2331/5331

  42. Net Flow Property II • Cut Lemma: Given a flow in a network for any cut , the net flow is at most the cut capacity. That is, for any cut . • Proof: • Follows from definitions. • Corollary: Given a flow network let be the max flow of . Then, for any cut . CSE 2331/5331

  43. Example • Recall max-flow has value 14. • What is the min-cut of this network? CSE 2331/5331

  44. Another Example • Recall the max-flow has value 11 • What is the min-cut? CSE 2331/5331

  45. In general, how to compute Min-cut? CSE 2331/5331

  46. Max-Flow Min-Cut Theorem • Max-Flow Min-Cut Theorem: For any flow network the value of max-flow of = capacity of min-cut of . • Max-Flow Min-Cut Theorem Version-2: For any flow network the following three statements are equivalent: (1) is max-flow of (2) There is no augmenting path in residual network (3) for some cut of . CSE 2331/5331

  47. Proof Sketch • : easy. Discussed before. • : Assume has no augmenting path. • Set reachable from in • Set . (So vertices in T not reachable from s.) • Since there is no edge in from any to • Total flow from S to T = • Total flow from T to S = 0 • Hence net-flow =. • : follow from Cut-Lemma and its Corollary. CSE 2331/5331

  48. Computing Min-Cut • But proof of , once we compute the max-flow, we can compute a min-cut from it. Max flow CSE 2331/5331

  49. Bipartite Matching CSE 2331/5331

  50. Matching in Bipartite Graph • Bipartite graph: • Graph G = (V, E) , where V = L  R, and no edge in E crosses (L, R). • A matching in bipartite graph is • A subset of edges M from E, where at most one edge from M is incident on any v  V. • Maximum matching in bipartite graph • A matching with largest cardinality CSE 2331/5331

More Related