Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.

Similar presentations


Presentation on theme: "CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some."— Presentation transcript:

1 CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some by Iker Gondra

2 Cuts Def: An s-t cut is a partition (A, B) of V with s  A and t  B Def: The capacity of a cut (A, B) is: s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 Capacity = 10 + 5 + 15 = 30 A

3 Cuts Def: An s-t cut is a partition (A, B) of V with s  A and t  B Def: The capacity of a cut (A, B) is: s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 A Capacity = 9 + 15 + 8 + 30 = 62

4 Minimum Cut Problem Min s-t cut problem: Find an s-t cut of minimum capacity s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 A Capacity = 10 + 8 + 10 = 28

5 Find a Minimum Cut u st v 40 10

6 Find a Minimum Cut s t 6 6 10 7 3 5 36 2 4 5 8 5 4 8 a b c d e f g h

7 Interesting point We’ll see -- problem of finding min cut is solved using FF technique Definition: the net flow across the cut = sum of the flows out of A minus the sum of the flows into A ( written as f out (A) –f in (A) )

8 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: 10 6 6 11 1 10 3 8 8 0 0 0 11 s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 0 Value = 24 4 A

9 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: 10 6 6 1 3 8 8 0 0 0 11 s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 0 Value = 6 + 0 + 8 - 1 + 11 = 24 4 11 A

10 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: 10 6 6 11 1 10 3 8 8 0 0 0 11 s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 0 Value = 10 - 4 + 8 - 0 + 10 = 24 4 A

11 Let us see how to prove the flow value lemma Proof: v(f) =  f(e) =  f(e) -  f(e) (def and s is source) e out of s e out of s e into s = f out (s) - f in (s) (definition) =  ( f out (v) - f in (v) ) conservation: nodes in A except s are internal v in A =  (  f(e) -  f(e) ) (definition) v in A e out of v e into v =  f(e) -  f(e) = f out (A) –f in (A) e out of A e into A (reason for second-last equality: if e has both ends in A, f(e) appears once with a + and once with a – and they cancel; if e has tail in A it appears with a +; if it has its head in A it appears with a minus).

12 Flows and Cuts Flow value lemma: Let f be any flow, and let (A, B) be any s-t cut. Then Proof: previous slide Thus by watching the amount of flow f sends across a cut we can measure the value of the flow – it is the amount out minus the amount in.

13 Relationship of Flows and Cuts We shall show: Let f be any flow, and let (A, B) be any s- t cut. Then the value of the flow is at most the capacity of the cut Cut capacity = 30  Flow value  30 s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 Capacity = 30 A

14 Flows and Cuts Flow/Cut Lemma : Let f be any flow. Then, for any s-t cut (A, B) we have v(f)  cap(A, B) Proof: = v(f) = f out (A) - f in (A) flow value lemma (and definition) ≤ f out (A) =  f(e) definition e out of A ≤  c(e) capacity condition e out of A = c(A,B) definition The corollary below follows from the flow/cut lemma – do you see why??? (Focus on the two any’s in the statement of the lemma)

15 Certificate of Optimality Corollary: Let f be any flow, and let (A, B) be any cut. If v(f) = cap(A, B), then f is a max flow and (A, B) is a min cut Value of flow = 28 Cut capacity = 28  Flow value  28 10 9 9 14 4 10 4 8 9 1 0 0 0 14 s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 0 A

16 The Ford-Fulkerson Algorithm terminates when the flow f has no s-t path in G f This is the property needed to prove its maximality

17 Max-Flow = Min Cut Theorem: If f is an s-t flow such that there is no s-t path in G f, then there is an s-t cut (A*,B*) for which v(f) = c(A*,B*). Consequently, f has the maximum value of any flow in G and (A*,B*) has the minimum capacity of any s-t cut. Proof: The second statement is the above corollary; so all we need to do is prove the first statement. Assume we have an s-t flow such that there is no s-t path in G f.Here is how to find (A*,B*): Let A* denote the set of nodes {v} such that there is an s-v path in G f. Let B* = V - A*.; then:

18 Proof of Max-Flow Min-Cut Theorem 1. (A*, B*) is a cut (Why?? --- well s is in A* and t must be in B* as there is no s-t path in G f ) 2. If e=(u,v) is an edge in G with u in A* and v in B*, then f(e) = c(e) (Why?? If not, e is a forward in edge in G f and thus there would be an s-v path in G f – impossible as v is in B*) 3. In a similar manner we can show that if e’ = (u’, v’) is an edge in G with u’ in B* and v’ in A*, then f(e’) = 0 (if not consider the backward edge (v’,u’) in G f ; it gives rise to an s-u’ path in G f (via s-v’-u’) – impossible as u’ is in B*) From 2 and 3 we conclude that all edges e out of A* are completely saturated with flow (i.e., f(e) = c(e)) while all edges e into A* are completely unused (i.e., f(e) = 0).

19 Proof of Max-Flow Min-Cut Theorem Thus: v(f) = f out (A*) – f in (A*) flow value lemma ((A*, B*) is a cut) = Σ f(e) - Σ f(e) definition e out of A* e into A* = Σ c(e) - 0 previous slide justifies this e out of A* = c(A*,B*) definition

20 Max-Flow Min-Cut Theorem Ford-Fulkerson algorithm finds a flow where the residual graph G f is disconnected, thus we can’t increase the flow any more; hence FF finds a maximum flow. If we want to find a minimum cut, we begin by finding a maximum flow. Then using the G f obtained by FF, perform a BFS to determine the set of nodes A* that s can reach. If B* = V–A*, (A*,B*) is a cut of minimum capacity.


Download ppt "CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some."

Similar presentations


Ads by Google