Top Banner
Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009
36

Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Karger’s Min-Cut Algorithm

Amihood Amir

Bar-Ilan University, 2009

Page 2: 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-E1) is

not connected.

EE 1

Page 3: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Example

A

C

B

D

GE

F

Page 4: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Example

A

C

B

D

GE

F

E1 = BE

Page 5: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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) )

Page 6: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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

Page 7: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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: )( 4nO

Page 8: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Randomized Solution

Repeat Until 2 nodes left:1. choose edge at random2. “contract” edge

When only 2 node left:Take all edges between them as the min-cut.

Time: O(|E|)=O(n²)

Page 9: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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).

Page 10: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Example:A

C

B

D

GE

F

Page 11: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Example:A

C

B

D

GE

Fcontract

Page 12: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Example:A

C

B

D

GE

Fcontract

A

C

B

D

E

FG

Page 13: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Example:A

C

B

D

GE

Fcontract

A

C

B

D

E

FG

contract

Page 14: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Example:A

C

B

D

GE

Fcontract

A

C

B

D

E

FG

contract

A

C

B E

FGD

Page 15: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Is output min-cut?

Not necessarily.

Is it a cut?

- yes.

Page 16: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Is output min-cut?

Not necessarily.

Is it a cut?

- yes.

Could there be an edge

between these sides that

was deleted?

Page 17: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Is output min-cut?

Not necessarily.

Is it a cut?

- yes.

No. The only deleted

edges were within

the contractions.

Page 18: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Is output min-cut?

Not necessarily.

Is it a cut?

- yes.

cut C={e1,…,ec}No. The only deleted

edges were within

the contractions.

Page 19: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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?

Page 20: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Probability calculation

Note: We can assume that degree of every node in graph throughout contraction process ≥ c

Page 21: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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.

Page 22: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Probability calculationProbability 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 ≥:

nncc

Ec 2

2/

incin

c

2

2/)(

inin

in

221

Page 23: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Probability calculationNote: The algorithm has n-2 stages (at that

point 2 nodes are left).

Probability of not choosing an edge from C at any stage ≥

=

)1)(1)(1()1)(1)(1)(1( )3(2

)4(2

)5(2

32

22

122

nnnnnnnnnn

))()(())()()(( 31

42

53

35

24

132

nn

nn

nn

nn

Page 24: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Probability calculationWhat do we have?

))()(())()()(( 31

42

53

35

24

132

nn

nn

nn

nn

Page 25: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Probability calculationWhat do we have?

Telescope cancellations:

))()(())()()(( 31

42

53

35

24

132

nn

nn

nn

nn

))()(())()()(( 31

42

53

35

24

132

nn

nn

nn

nn

)( 21

)1(2

nOnn

=

Page 26: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

ConcludeRun the algorithm O(n²) times and expect to get C with constant probability.

Total time:

No better than Ford-Fulkerson!

Can we do better? )( 4nO

Page 27: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

IDEA!The situation:

n² results, one of which is expected to be good. O(n²)time

Page 28: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

What if?Could compute:

n² results, one of which is expected to be good.O(log n)time

Page 29: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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 ≥

n21

)())(())(( 2

2)()1(

)2)(1(211

132

n

innn

ininin

ininin

nn

nn O

Page 30: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

So what is the situation?

When is the probability of not hitting C exactly ½ ?

-- When nodes are left.

Because take then

2n

122

n

i

21

2

2

2

2

2

22

2

22

2

122

nnn

nn

n

n nnnn

Page 31: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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!

2

n

2

n

Page 32: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Time:

)()(2)( 2

2nOTnT n

)log( 2 nnO

The closed form is:

Much better!But what is the overall probability?

Page 33: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Probability:

Assume we are in level d of the recursiontree, with the leaves being level 1.

Let Pd(x) be the probability that there is apath 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 touchC)

Page 34: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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.

Page 35: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

Probability:We have:Pd = Pd-1 – ½ (Pd-1)².

Inductively: Pd-1 >1/(d-1). So, because of monotonicity, Pd-1 – ½ (Pd-1)² >

ddd

d

ddddd

1

)1(

1

)1(

1

1

1

)1(2

1

1

12

Page 36: Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009.

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)