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

36
Karger’s Min-Cut Algorithm Amihood Amir Bar-Ilan University, 2009
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    0

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

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

Example

A

C

B

D

GE

F

Example

A

C

B

D

GE

F

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

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

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:A

C

B

D

GE

F

Example:A

C

B

D

GE

Fcontract

Example:A

C

B

D

GE

Fcontract

A

C

B

D

E

FG

Example:A

C

B

D

GE

Fcontract

A

C

B

D

E

FG

contract

Example:A

C

B

D

GE

Fcontract

A

C

B

D

E

FG

contract

A

C

B E

FGD

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

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

Probability calculationWhat do we have?

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

42

53

35

24

132

nn

nn

nn

nn

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

=

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

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 ≥

n21

)())(())(( 2

2)()1(

)2)(1(211

132

n

innn

ininin

ininin

nn

nn O

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

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

Time:

)()(2)( 2

2nOTnT n

)log( 2 nnO

The closed form is:

Much better!But what is the overall probability?

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)

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

ddd

d

ddddd

1

)1(

1

)1(

1

1

1

)1(2

1

1

12

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)