Download presentation
Presentation is loading. Please wait.
1
Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009
2
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.
3
Example A C B D G E F
4
A C B D G E F E 1 = BE
5
Immediate Solution For every pair of nodes s,t find the min-cut M s,t Choose the pair with the smallest M s,t. Time= O(n² T(min-cut) )
6
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
7
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:
8
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²)
9
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).
10
Example: A C B D G E F
11
A C B D G E F contract
12
Example: A C B D G E F contract A C B D E FG
13
Example: A C B D G E F contract A C B D E FG contract
14
Example: A C B D G E F contract A C B D E FG contract A C BE FGD
15
Is output min-cut? Not necessarily. Is it a cut? -yes.
16
Is output min-cut? Not necessarily. Is it a cut? -yes. Could there be an edge between these sides that was deleted?
17
Is output min-cut? Not necessarily. Is it a cut? -yes. No. The only deleted edges were within the contractions.
18
Is output min-cut? Not necessarily. Is it a cut? -yes. cut C ={e 1,…,e c } No. The only deleted edges were within the contractions.
19
When is C a min-cut? When none of the edges in C={e 1,…,e c } are chosen to be contracted. What is the probability of that happening?
20
Probability calculation Note: We can assume that degree of every node in graph throughout contraction process ≥ c
21
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.
22
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 ≥:
23
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 ≥ =
24
Probability calculation What do we have?
25
Probability calculation What do we have? Telescope cancellations: =
26
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?
27
IDEA! The situation: n² results, one of which is expected to be good. O(n²) time
28
What if? Could compute: n² results, one of which is expected to be good. O(log n) time
29
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 ≥
30
So what is the situation? When is the probability of not hitting C exactly ½ ? -- When nodes are left. Because take then
31
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!
32
Time: The closed form is: Much better! But what is the overall probability?
33
Probability: Assume we are in level d of the recursion tree, with the leaves being level 1. Let P d (x) be the probability that there is a path from node x at level d that does not touch C. We have: P d (x)= ½ (Probability that at least one of the two recursions does not touch C )
34
Probability: Recall: Pr(A or B)= Pr(A)+Pr(B)-Pr(A and B) We have: P d (x)= ½ (2P d-1 -(P d-1 )²) Where P d-1 is the probability that a child of x does not hit C. = P d-1 – ½ (P d-1 )² Claim: For d >1, P d >1/d Proof: Note that in the interval [0,1) the function x – ½ x² decreases monotonically.
35
Probability: We have: P d = P d-1 – ½ (P d-1 )². Inductively: P d-1 >1/(d-1). So, because of monotonicity, P d-1 – ½ (P d-1 )² >
36
Probability: Conclude: P log 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)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.