450 likes | 1.16k Views
Karger’s Min-Cut Algorithm. Amihood Amir Bar-Ilan University, 2009. The Problem. INPUT: Undirected Graph G=(V,E) OUTPUT: A smallest-size set of edges such that G’=(V,E-E 1 ) is not connected. Example. F. A. B. E. G. C. D. Example.
E N D
Karger’sMin-Cut Algorithm Amihood Amir Bar-Ilan University, 2009
The Problem INPUT: Undirected Graph G=(V,E) OUTPUT: A smallest-size set of edges such that G’=(V,E-E1) is not connected.
Example F A B E G C D
Example F A B E G C D E1 = BE
Immediate Solution For every pair of nodes s,t find the min-cut Ms,t Choose the pair <s,t> with the smallest Ms,t. Time= O(n² T(min-cut) )
Time for Min-Cut Ford-Fulkerson:O(|E|flow) In our case: max flow ≤ n so: O(n² |E|n) = O(n² n³) This can be improved
Improvement We don’t need all pairs. Why? Every node is in one side of a cut. Therefore: Fix node s. Try all other n-1 options as node t. Time:
Randomized Solution Repeat Until 2 nodes left: 1. choose edge at random 2. “contract” edge When only 2 node left: Take all edges between them as the min-cut. Time:O(|E|)=O(n²)
Meaning of “contraction” Make edge ab with its two adjacent nodes a,b into a single node ab. All edges of a and b will now be edges from ab (creating a multigraph).
Example: F A B E G C D
Example: F A contract B E G C D
Example: F A contract B E G C D FG A B E C D
Example: F A contract B E G C D FG A B E C D contract
Example: F A contract B E G C D FG FGD A A B E B E C D C contract
Is output min-cut? Not necessarily. Is it a cut? • yes.
Is output min-cut? Not necessarily. Is it a cut? • yes. Could there be an edge between these sides that was deleted?
Is output min-cut? Not necessarily. Is it a cut? • yes. No. The only deleted edges were within the contractions.
Is output min-cut? Not necessarily. Is it a cut? • yes. cut C={e1,…,ec} No. The only deleted edges were within the contractions.
When is C a min-cut? When none of the edges in C={e1,…,ec} are chosen to be contracted. What is the probability of that happening?
Probability calculation Note: We can assume that degree of every node in graph throughout contraction process ≥ c
Probability calculation Note: We can assume that degree of every node in graph throughout contraction process ≥ c Otherwise: Cut node and get cut of size < c.
Probability calculation Probability that one of the C edges is chosen at first stage: Probability that one of the C edges is chosen after stage i ≤: Probability of not choosing an edge of C at stage i ≥:
Probability calculation Note: The algorithm has n-2 stages (at that point 2 nodes are left). Probability of not choosing an edge from C at any stage ≥ =
Probability calculation What do we have?
Probability calculation What do we have? Telescope cancellations: =
Conclude Run the algorithm O(n²) times and expect to get C with constant probability. Total time: No better than Ford-Fulkerson! Can we do better?
IDEA! The situation: n² results, one of which is expected to be good. O(n²) time
What if? Could compute: n² results, one of which is expected to be good. O(log n) time
This is not quite the situation… But note: The probability of not hitting C at stage 1 is (almost 1). It grows as we run more and more stages. What happens if we stop in the middle? The probability that C not touched in the first i steps ≥
So what is the situation? When is the probability of not hitting C exactly ½ ? -- When nodes are left. Because take then
This means If we run two times until nodes are left we expect that one of them still did not touch C So, for each of these runs, when nodes are left, stop running and recurse!
Time: The closed form is: Much better! But what is the overall probability?
Probability: Assume we are in level d of the recursion tree, with the leaves being level 1. Let Pd(x) be the probability that there is a path from node x at level d that does not touch C. We have: Pd(x)= ½ (Probability that at least one of the two recursions does not touch C)
Probability: Recall: Pr(A or B)= Pr(A)+Pr(B)-Pr(A and B) We have: Pd(x)= ½(2Pd-1-(Pd-1)²)Where Pd-1 is the probability that a child of x does not hit C. = Pd-1 – ½ (Pd-1)² Claim: For d >1, Pd >1/d Proof:Note that in the interval [0,1) the function x – ½ x² decreases monotonically.
Probability: We have: Pd = Pd-1 – ½ (Pd-1)². Inductively: Pd-1 >1/(d-1). So, because of monotonicity, Pd-1– ½ (Pd-1)² >
Probability: Conclude: Plog n(x) > 1/log n Which means:If we run the algorithm log n times, we get constant probability. So… Total time: O(n² log² n)