chapter 8 the max flow min cut theorem
play

Chapter 8 The Max-Flow Min-Cut Theorem Prof. Tesler Math 154 - PowerPoint PPT Presentation

Chapter 8 The Max-Flow Min-Cut Theorem Prof. Tesler Math 154 Winter 2020 Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 1 / 60 Flows B D A E C Consider sending things through a network Application Rate (e.g., amount per unit time)


  1. Chapter 8 The Max-Flow Min-Cut Theorem Prof. Tesler Math 154 Winter 2020 Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 1 / 60

  2. Flows B D A E C Consider sending things through a network Application Rate (e.g., amount per unit time) Water/oil/fluids through pipes GPM: gallons per minute Electrical current through circuit A: amperage = coulombs/sec Trains along rail network Kilotons/year Data through computer network Mbps: megabits/sec Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 2 / 60

  3. Flows B D A E C We send things through a digraph from a source vertex, s , to a sink vertex, t . For the network above, we’ll use s = A and t = E . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 3 / 60

  4. Flows B D A E C Simplifications Graph is directed and simple (no loops, no multiple edges). Source s has edges going out, but not in; Sink t has edges going in, but not out. If ( x , y ) is an edge, then ( y , x ) isn’t. These are simplifications for our first time through it. We’ll remove these restrictions later. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 4 / 60

  5. Flows B D 3 3 A E 3 C Send 3 units from source to sink on path ABCE . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 5 / 60

  6. Flows 2 B D 2 5 3 A E 3 C Also send 2 units from source to sink on path ABDE . The total units along each edge is marked. Both paths contribute to the flow on edge AB . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 6 / 60

  7. Flows 2 B D 2 5 3 A E 3 C We consider static flows , meaning no time-dependence. Examples: Steady state: 5 units/sec on AB, 2 on BD, etc. Aggregated flow: each month, 5 units on AB, 2 on BD, etc. A static st -flow means a static flow from source s to sink t (similar to terminology uv -paths ). Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 7 / 60

  8. Flow function 2 B D 2 5 3 A E 3 C A flow from s to t is a function f : E ( G ) → R � 0 from the edges to the nonnegative reals, such that for all vertices x except s and t , � � B : 5 = 3 + 2 f ( w , x ) = f ( x , y ) C : 3 = 3 w ∈ N − ( x ) y ∈ N + ( x ) flow into x = flow out of x D : 2 = 2 The flow is shown as numbers on the edges ( f ( x , y ) = 0 if not shown or if ( x , y ) is not an edge). Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 8 / 60

  9. Flow function 2 B D 2 5 3 A E 3 C A flow from s to t is a function f : E ( G ) → R � 0 from the edges to the nonnegative reals, such that for all vertices x except s and t , � � B : 5 = 3 + 2 f ( w , x ) = f ( x , y ) C : 3 = 3 w ∈ N − ( x ) y ∈ N + ( x ) flow into x = flow out of x D : 2 = 2 This equation is called Kirchhoff’s Law . Kirchhoff developed this law for electrical circuits. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 9 / 60

  10. Flow function 2 B D 2 5 3 A E 3 C We started with a flow f ( x , y ) = 0 everywhere. 1 We added yellow path ABCE: 2 Increases in- & out-flow at B and C by 3, keeping them balanced. Adds 3 to out-flow at source A / in-flow at sink E , so they’re not balanced. Green path ABDE increases in- & out-flow at B and D by 2 3 (keeping them balanced) and adds 2 to out-flow at A / in-flow at E. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 10 / 60

  11. Value of a flow 2 B D 2 5 3 A E 3 C The value of a flow is � � v ( f ) = f ( s , y ) − f ( w , s ) (using source) y ∈ N + ( s ) w ∈ N − ( s ) � � = f ( w , t ) − f ( t , y ) (using sink) w ∈ N − ( t ) y ∈ N + ( t ) At source A : v ( f ) = 5 − 0 = 5 . At sink E : v ( f ) = ( 3 + 2 ) − 0 = 5 . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 11 / 60

  12. Value of a flow The value of a flow is � � v ( f ) = f ( s , y ) − f ( w , s ) (using source) y ∈ N + ( s ) w ∈ N − ( s ) � � = f ( w , t ) − f ( t , y ) (using sink) w ∈ N − ( t ) y ∈ N + ( t ) Usually, there are no edges into a source or out from a sink, so the subtracted sums are 0 . However, this formula allows for such edges (in which case the subtracted sums might not be 0 ). Alternate notation: | f | is common instead of v ( f ) . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 12 / 60

  13. Capacities 2/15 B D 2/10 5/30 0/20 3/5 A E 3/30 0/3 C Each edge has an upper limit on its flow, called the capacity. A 2 inch steel water pipe has a maximum flow of 45 gallons/minute. Wi-Fi download speed capped at 25 Mbps. Cell phone capped at 5 Mbps. These are examples, and may vary by company / equipment / etc. Notation: Write two numbers on each edge: flow / capacity E.g., edge DE: 2/10 means the flow is 2, out of a capacity 10. It is not division giving 0.2. It is not a fraction; can’t replace 2 / 10 by 1 / 5 . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 13 / 60

  14. Capacities 2/15 B D 2/10 5/30 0/20 3/5 A E 3/30 0/3 C For each edge: f ( x , y ) = flow on edge ( x , y ) c ( x , y ) = capacity on edge ( x , y ) We require 0 � f ( x , y ) � c ( x , y ) for every edge. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 14 / 60

  15. Maximum Flow 2/15 B D 2/10 5/30 0/20 3/5 A E 3/30 0/3 C Goal: Find a flow maximizing v ( f ) , subject to the capacities. Strategy: Keep finding augmenting paths from source to sink, on which we can add flow. The two paths so far are examples. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 15 / 60

  16. Paths with backwards edges 2/15 B D 2/10 5/30 0/20 3/5 A E 3/30 0/3 C We will allow paths with backwards edges! Consider path ACBDE above. Edge CB is traversed backwards; other edges are forwards. We will “send” 2 units along the yellow path. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 16 / 60

  17. Paths with backwards edges 2/15 4/15 B D B D 2/10 4/10 5/30 5/30 0/20 0/20 3/5 1/5 A E A E 3/30 3/30 0/3 2/3 C C Add 2 to the flow on each forwards edge. Subtract 2 from the flow on each reverse edge. This keeps the internal nodes balanced, and increases v ( f ) by 2 . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 17 / 60

  18. Paths with backwards edges 2/15 4/15 B D B D 2/10 4/10 5/30 5/30 0/20 0/20 3/5 1/5 A E A E 3/30 3/30 0/3 2/3 C C Interpretation of using backwards edges: Nothing actually goes backwards! Instead, some paths are rerouted and spliced together differently. 2 units on A → B → C → E are redirected to A → B → D → E . So BC and CE go down 2, while BD and DE go up 2. The 2 units just lost on CE are replaced by 2 new units from AC. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 18 / 60

  19. Residual capacity 2/15 B D 2/10 5/30 0/20 3/5 A E 3/30 0/3 C Back up to before we added 2 to the yellow path. How much could we have added to this path, without going over any edge’s capacity? Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 19 / 60

  20. Residual capacity 2/15 B D 2/10 5/30 0/20 3/5 A E 3/30 0/3 C Let x 0 x 1 . . . x r be a path in the undirected graph from x 0 = s to x r = t . Using edges in the wrong direction is allowed. The residual capacity of an edge is  if ( u , v ) ∈ E ( G ) ; c ( u , v ) − f ( u , v )  c f ( u , v ) = f ( v , u ) if ( v , u ) ∈ E ( G ) ;  otherwise. 0 c f ( A , C ) = 3 , c f ( C , B ) = 3 , c f ( B , D ) = 13 , c f ( D , E ) = 8 . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 20 / 60

  21. Residual capacity 2/15 B D 2/10 5/30 0/20 3/5 A E 3/30 0/3 C Residual capacities along path: c f ( A , C ) = 3 , c f ( C , B ) = 3 , c f ( B , D ) = 13 , c f ( D , E ) = 8 . Let ǫ be the minimum of these: � � ǫ = min c f ( x i − 1 , x i ) : i = 1 , . . . , r (here, ǫ = 3 ) This is the maximum that we can increase the flow along the path (we have to pick a number that works for all edges on the path). If a path has ǫ > 0 , it is called an augmenting path . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 21 / 60

  22. Residual capacity 2/15 5/15 B D B D 2/10 5/10 5/30 5/30 0/20 0/20 3/5 0/5 A E A E 3/30 3/30 0/3 3/3 C C Use this augmenting path to increase the flow by ǫ = 3 . Along the path, add ǫ to the flow for each forwards edge, and subtract it for each reverse edge. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 22 / 60

  23. Ford-Fulkerson Algorithm Ford-Fulkerson Algorithm / Method Given a digraph G , source s , sink t , and edge capacities c ( x , y ) : Initialize f ( x , y ) = 0 for all vertices x , y . 1 While there is any augmenting path (from s to t with ǫ > 0 ): 2 Increase f by ǫ along forwards edges of the path, and decrease f by ǫ along reverse edges. Ford & Fulkerson didn’t say the specific way to find the paths. People have improved this by developing specific ways to find augmenting paths. Edmonds-Karp Algorithm: use breadth first search to find a shortest (# edges) augmenting path at each step. Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 23 / 60

  24. Ford-Fulkerson Algorithm 0/15 0/15 B D B D 0/10 0/10 0/30 5/30 0/20 0/20 0/5 5/5 A E A E 0/30 5/30 0/3 0/3 C C Start over with the same graph. Originally we sent 3 units on this yellow path, ABCE . Now instead, we use the maximum amount possible: ǫ = 5 . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 24 / 60

  25. Ford-Fulkerson Algorithm 0/15 10/15 B D B D 0/10 10/10 5/30 15/30 0/20 0/20 5/5 5/5 A E A E 5/30 5/30 0/3 0/3 C C Send ǫ = 10 on path ABDE . Prof. Tesler Ch. 8: Flows Math 154 / Winter 2020 25 / 60

Recommend


More recommend