Top Banner
A Simple Min-Cut Algorithm Joseph Vessella Rutgers-Camden 1
55

A Simple Min-Cut Algorithm

Dec 30, 2015

Download

Documents

Julian Murphy

A Simple Min-Cut Algorithm. Joseph Vessella Rutgers-Camden. The Problem. Input: Undirected graph G =( V , E ) Edges have non-negative weights Output: A minimum cut of G. Cut Example. Cut: set of edges whose removal disconnects G Min-Cut: a cut in G of minimum cost. - PowerPoint PPT Presentation
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: A Simple Min-Cut Algorithm

1

A Simple Min-Cut Algorithm

Joseph VessellaRutgers-Camden

Page 2: A Simple Min-Cut Algorithm

2

The Problem

• Input: Undirected graph G=(V,E) Edges have non-negative weights

• Output: A minimum cut of G

Page 3: A Simple Min-Cut Algorithm

3

Cut Example

Weight of this cut: 11 Weight of min cut: 4

Cut: set of edges whose removal disconnects GMin-Cut: a cut in G of minimum cost

Page 4: A Simple Min-Cut Algorithm

4

s-t Cut Example

Weight of this a-d cut: 11 Weight of min a-d cut: 4

s-t cut: cut with s and t in different partitionss = a and t = d

Page 5: A Simple Min-Cut Algorithm

5

Naive Solution

• Check every possible cut • Take the minimum

• Running time: O(2n)

Page 6: A Simple Min-Cut Algorithm

6

Previous Work

• Ford-Fulkerson, 1956 Input: Directed Graph with weights on edges

and two vertices s and t Output: Directed min cut between s and t

Page 7: A Simple Min-Cut Algorithm

7

Possible Solution

• Make edges bidirected• Fix an s, try all other vertices as t• Return the lowest cost solution

• Running time: O(n x n3) = O(n4)

Page 8: A Simple Min-Cut Algorithm

8

Previous Work

• Hao & Orlin, 1992, O(nm log(n²/m))• Nagamochi & Ibaraki, 1992, O(nm + n²log(n))• Karger & Stein (Monte Carlo), 1993, O(n²log3(n))• Stoer & Wagner, JACM 1997, O(nm + n²log(n))

Page 9: A Simple Min-Cut Algorithm

9

The Algorithm

MinCutPhase(G, w):a ← arbitrary vertex of GA ← (a)While A ≠ V

v ← vertex most tightly connected to AA ← A U (v)

s and t are the last two vertices (in order) added to AReturn cut(A-t,t)

Page 10: A Simple Min-Cut Algorithm

10

Most Tightly Connected Vertex

MTCV is the vertex whose sum of edge weights into A is max.

Page 11: A Simple Min-Cut Algorithm

11

The Algorithm

MinCutPhase(G, w):a ← arbitrary vertex of GA ← (a)While A ≠ V

v ← vertex most tightly connected to AA ← A U (v)

s and t are the last two vertices (in order) added to AReturn cut(A-t,t)

Page 12: A Simple Min-Cut Algorithm

12

Example A: (a) A: (a,b)

Page 13: A Simple Min-Cut Algorithm

14

ExampleA: (a,b,c) A: (a,b,c,d)

Page 14: A Simple Min-Cut Algorithm

16

ExampleA: (a,b,c,d,e) A: (a,b,c,d,e,f)

Page 15: A Simple Min-Cut Algorithm

17

Example

s = e and t = f

Page 16: A Simple Min-Cut Algorithm

19

The Algorithm

MinCutPhase(G, w):a ← arbitrary vertex of GA ← (a)While A ≠ V

v ← vertex most tightly connected to AA ← A U (v)

s and t are the last two vertices (in order) added to AReturn cut(A-t,t)

Page 17: A Simple Min-Cut Algorithm

20

Key Result

Theorem: MinCutPhase returns a min s-t cut

Page 18: A Simple Min-Cut Algorithm

21

Implications

What if min cut of G separates s and t?

Page 19: A Simple Min-Cut Algorithm

22

Implications

What if min cut of G separates s and t?

Then min s-t cut is also a min cut of G

Page 20: A Simple Min-Cut Algorithm

23

Implications

What if min cut of G separates s and t?

Then min s-t cut is also a min cut of G

What if min cut of G does not separate s and t?

Page 21: A Simple Min-Cut Algorithm

24

Implications

What if min cut of G separates s and t?

Then min s-t cut is also a min cut of G

What if min cut of G does not separate s and t?

Then s and t are in the same partition of min cut

Page 22: A Simple Min-Cut Algorithm

25

The Algorithm

MinCut(G,w):w(minCut) ← ∞While |V| > 1

s-t-phaseCut ← MinCutPhase(G,w)if w(s-t-phaseCut) < w(minCut)

minCut ← s-t-phaseCutMerge(G,s,t)

Return minCut

Page 23: A Simple Min-Cut Algorithm

26

Merge(G,e,f)

Merge(G,e,f): G ← G\{e,f} U {ef}For v ∈ V, v ≠ {ef}

w(ef, v) is sum of w(e,v) and w(f,v) in orig. graph

Page 24: A Simple Min-Cut Algorithm

27

The Algorithm

MinCut(G,w):w(minCut) ← ∞While |V| > 1

s-t-phaseCut ← MinCutPhase(G,w)if w(s-t-phaseCut) < w(minCut)

minCut ← s-t-phaseCutMerge(G,s,t)

Return minCut

Page 25: A Simple Min-Cut Algorithm

28

Example

We already did one MinCutPhase

s = e and t = f

Page 26: A Simple Min-Cut Algorithm

29

The Algorithm

MinCut(G,w):w(minCut) ← ∞While |V| > 1

s-t-phaseCut ← MinCutPhase(G,w)if w(s-t-phaseCut) < w(minCut)

minCut ← s-t-phaseCutMerge(G,s,t)

Return minCut

Page 27: A Simple Min-Cut Algorithm

30

ExampleA: (a) A: (a,b)

Page 28: A Simple Min-Cut Algorithm

32

ExampleA: (a,b,c) A: (a,b,c,d)

Page 29: A Simple Min-Cut Algorithm

33

ExampleA: (a,b,c,d)

s = d and t = ef

Page 30: A Simple Min-Cut Algorithm

35

ExampleA: (a) A: (a,b)

Page 31: A Simple Min-Cut Algorithm

37

ExampleA: (a,b,c)

s = c and t = efd

Page 32: A Simple Min-Cut Algorithm

38

ExampleA: (a) A: (a,b)

Page 33: A Simple Min-Cut Algorithm

39

ExampleA: (a,b)

s = b and t = cefd

Page 34: A Simple Min-Cut Algorithm

40

ExampleA: (a)

Page 35: A Simple Min-Cut Algorithm

41

ExampleA: (a)

s = a and t = cefdb

Page 36: A Simple Min-Cut Algorithm

42

Example

• We found the min cut of G as 4 when we were in the following MinCutPhase

Page 37: A Simple Min-Cut Algorithm

46

Correctness

MinCutPhase(G, w):a ← arbitrary vertex of GA ← (a)While A ≠ V

v ← vertex most tightly connected to AA ← A U (v)

s and t are the last two vertices (in order) added to AReturn cut(A-t,t)

Page 38: A Simple Min-Cut Algorithm

47

Correctness

Theorem: (A-t, t) is always a min s-t cut

Proof: We want to show that w(A-t, t) ≤ w(C) for any arbitrary s-t cut C

Page 39: A Simple Min-Cut Algorithm

48

Notation

A ← (a, b, c, d, e, f)

Av: set of vertices added to A before v

Ad ← {a, b, c}

Cv: cut of Av U {v} induced by C

C: arbitrary s-t cut

Page 40: A Simple Min-Cut Algorithm

49

NotationA: (a, b, c, d, e, f)

Ce C

Page 41: A Simple Min-Cut Algorithm

50

Active Vertexvertex in A in the opposite partition of C from the

one before itA: (a,b,c,d,e,f)C

Page 42: A Simple Min-Cut Algorithm

51

Correctness

Lemma: For all active vertices v, w(Av,v) ≤ w(Cv)

Page 43: A Simple Min-Cut Algorithm

52

Correctness

Since t is always active and Ct = C

w(At, t) ≤ w(C)

Thus MinCutPhase returns a min s-t cut

Theorem: (A-t, t) is always a min s-t cutProof: By the lemma, for an active vertex v

w(Av,v) ≤ w(Cv)

Page 44: A Simple Min-Cut Algorithm

53

Correctness

Lemma: For all active vertices v, w(Av,v) ≤ w(Cv)

Proof: Induction on the no. of active vertices, kBase case: k = 1, claim is true

A: (a, b, c, d)Cd

w(Ad,d) = w(Cd)

Page 45: A Simple Min-Cut Algorithm

54

Correctness

IH: Assume inequality holds true up to uv: first active vertex after u

w(Av, v) = w(Au, v) + w(Av - Au, v)

+=

u = d and v = f

A: (a,b,c,d,e,f)

Page 46: A Simple Min-Cut Algorithm

55

Correctness

≤ w(Cu) + w(Av - Au, v) (by IH) ≤ w(Cv)

w(Av, v) = w(Au, v) + w(Av - Au, v) ≤ w(Au, u) + w(Av - Au, v) (u is MTCV)

Page 47: A Simple Min-Cut Algorithm

56

Correctness• Edges crossing (Av - Au, v) cross C

• Contribute to Cv but not Cu u = d and v = fA: (a,b,c,d,e,f)

C = Cf(Av - Au, v) Cd

Page 48: A Simple Min-Cut Algorithm

57

Summary

Lemma: For all active vertices v, w(Av,v) ≤ w(Cv)

Theorem: (A-t, t) is always a min s-t cut

Page 49: A Simple Min-Cut Algorithm

58

Running Time

MinCutPhase(G, a):a ← arbitrary vertex of GA ← (a)While A ≠ V

v ← vertex most tightly connected to AA ← A U (v)

s and t are the last two vertices (in order) added to AReturn cut(A-t,t)

Page 50: A Simple Min-Cut Algorithm

59

Running Time

MinCutPhase(G, a):a ← arbitrary vertex of GA ← (a)While A ≠ V

v ← vertex most tightly connected to AA ← A U (v)

s and t are the last two vertices (in order) added to AReturn cut(A-t,t)

Page 51: A Simple Min-Cut Algorithm

60

Running TimeVertices not in A: priority queue with keykey(v) = w(A,v)

Can extract MTCV in log(n)

When v added to A, for each neighbor u of vkey(u) = key(u) + w(u, v)

So, we update the priority queue once per edge and get O(m + nlog(n)) per MinCutPhase

Page 52: A Simple Min-Cut Algorithm

61

The Algorithm

MinCut(G,w):w(minCut) ← ∞While |V| > 1

s-t-phaseCut ← MinCutPhase(G,w)if w(s-t-phaseCut) < w(minCut)

minCut ← s-t-phaseCutMerge(G,s,t)

Return minCut

Page 53: A Simple Min-Cut Algorithm

62

Running Time

• MinCut calls MinCutPhase n times• Get overall time of O(nm + n2log(n))

Page 54: A Simple Min-Cut Algorithm

63

Reference

M. Stoer and F. Wagner. A Simple Min-Cut Algorithm, JACM, 1997

Page 55: A Simple Min-Cut Algorithm

64

Thank You!