Stoer-Wagner Algorithm A Minimum Cut Algorithm for Undirected Graphs - - PowerPoint PPT Presentation

stoer wagner algorithm
SMART_READER_LITE
LIVE PREVIEW

Stoer-Wagner Algorithm A Minimum Cut Algorithm for Undirected Graphs - - PowerPoint PPT Presentation

The Algorithm Correctness Running Time Stoer-Wagner Algorithm A Minimum Cut Algorithm for Undirected Graphs BigNews CS214: Algorithms and Complexity Shanghai Jiao Tong University 2016.12.06 The Algorithm Correctness Running Time Outline


slide-1
SLIDE 1

The Algorithm Correctness Running Time

Stoer-Wagner Algorithm

A Minimum Cut Algorithm for Undirected Graphs BigNews

CS214: Algorithms and Complexity Shanghai Jiao Tong University

2016.12.06

slide-2
SLIDE 2

The Algorithm Correctness Running Time

Outline

The Algorithm Global Minimum Cut Stoer-Wagner Algorithm Correctness Lemma & Theorem Proof Running Time Proof

slide-3
SLIDE 3

The Algorithm Correctness Running Time

Global Minimum Cut

Definition

Given an undirected graph G(V, E), a global min-cut is a partition of V into two subsets (S, T) such that the sum of weights of edges between S and T is minimized.

1 5 2 6 3 4 7 8

w(1,2) = 2 2 2 2 2 2 3 3 3 3 4 1

slide-4
SLIDE 4

The Algorithm Correctness Running Time

Outline

The Algorithm Global Minimum Cut Stoer-Wagner Algorithm Correctness Lemma & Theorem Proof Running Time Proof

slide-5
SLIDE 5

The Algorithm Correctness Running Time

Stoer-Wagner Algorithm (1)

MinimumCutPhase(G, w, a)

1 A {a} 2 while (A 6= V) do 3

add to A the most tightly connected vertex

4 end 5 store the cut-of-the-phase 6 shrink G by merging the two vertices added last

slide-6
SLIDE 6

The Algorithm Correctness Running Time

Most Tightly Connected

Definition

A vertex t are called most ptightly connected to vertex set A if sum

  • f the weights of the edges connected between t and A is the highest

among other vertices not belonging to A.

1 5 2 6 3 4 7 8

2 2 2 2 2 2 3 3 3 3 4 1 5 3

slide-7
SLIDE 7

The Algorithm Correctness Running Time

A graph G = (V, E) with edge-weights 1 5 2 6 3 4 7 8

w(1,2) = 2 2 2 2 2 2 3 3 3 3 4 1

slide-8
SLIDE 8

The Algorithm Correctness Running Time

Start with vertex a = 2

1 5 2 6 3 4 7 8

2 2 2 2 2 2 3 3 3 3 4 1

a A = {2}

slide-9
SLIDE 9

The Algorithm Correctness Running Time

Add vertex b = 3

1 5 2 6 3 4 7 8

2 2 2 2 2 2 3 3 3 3 4 1

a b A = {2, 3}

slide-10
SLIDE 10

The Algorithm Correctness Running Time

Add vertex c = 4

1 5 2 6 3 4 7 8

2 2 2 2 2 2 3 3 3 3 4 1

a b c A = {2, 3, 4}

slide-11
SLIDE 11

The Algorithm Correctness Running Time

Add vertex d = 7

1 5 2 6 3 4 7 8

2 2 2 2 2 3 3 3 3 4 1

a b c

2

d A = {2, 3, 4, 7}

slide-12
SLIDE 12

The Algorithm Correctness Running Time

Add vertex e = 8

1 5 2 3 4 7 8

2 2 2 2 2 3 3 3 3 4

a b c

6

2 1

d e A = {2, 3, 4, 7, 8}

slide-13
SLIDE 13

The Algorithm Correctness Running Time

Add vertex f = 6

1 5 2 3 4 7 8

2 2 2 2 2 3 3 3 3 4

a b c

6

2 1

d e f A = {2, 3, 4, 7, 8, 6}

slide-14
SLIDE 14

The Algorithm Correctness Running Time

Add vertex s = 5 and vertex t = 1

1 5 2 3 4 7 8

2 2 2 2 2 3 3 3 3 4

a b c

6

2 1

d e f s t A = {2, 3, 4, 7, 8, 6, 5} A = {2, 3, 4, 7, 8, 6, 5, 1} s and t are the last two vertices (in order) added to A, and we get a cut C(A-t, t), which is so-called cut-of-the-phase.

slide-15
SLIDE 15

The Algorithm Correctness Running Time

Lemma

Each cut-of-the-phase is a minimum s-t cut in the current graph, where s and t are the two vertices added last in the phase.

1 5 2 3 4 7 8

2 2 2 2 2 3 3 3 3 4

a b c

6

2 1

d e f s t

slide-16
SLIDE 16

The Algorithm Correctness Running Time

Implications

What if the global min cut of G separates s and t?

slide-17
SLIDE 17

The Algorithm Correctness Running Time

Implications

What if the global min cut of G separates s and t? Then min s-t cut is also a global min cut of G.

slide-18
SLIDE 18

The Algorithm Correctness Running Time

Implications

What if the global min cut of G separates s and t? Then min s-t cut is also a global min cut of G. What if min cut of G does not separate s and t?

slide-19
SLIDE 19

The Algorithm Correctness Running Time

Implications

What if the global min cut of G separates s and t? Then min s-t cut is also a global 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 the global min cut, and we can merge them without changing the global min cut.

slide-20
SLIDE 20

The Algorithm Correctness Running Time

Merge

Definition

The two vertices are replaced by a new vertex and any edges from the two vertices to a remaining vertex are replaced by an edge weighted by the sum of the weights of the previous two edges, while edges joining the merged nodes are removed.

1 5 2 6 3 4 7 8

2 2 2 2 2 2 3 3 3 3 4 1

t a b c d e f s

slide-21
SLIDE 21

The Algorithm Correctness Running Time

Merge

Definition

The two vertices are replaced by a new vertex and any edges from the two vertices to a remaining vertex are replaced by an edge weighted by the sum of the weights of the previous two edges, while edges joining the merged nodes are removed.

1,5 2 6 3 4 7 8

4 2 2 2 2 3 3 3 4 1

a d e s t c b

slide-22
SLIDE 22

The Algorithm Correctness Running Time

Stoer-Wagner Algorithm (2)

MinimumCut(G, w, a)

1 while (| V |> 1) do 2

MinimumCutPhase(G, w, a)

3

if the cut-of-the-phase is lighter than the current minimum cut then

4

store the cut-of-the-phase as the current minimum cut

5

end

6 end

slide-23
SLIDE 23

The Algorithm Correctness Running Time

After the 1st MinimumCutPhase(G, ω, a), a = 2

1 5 2 6 3 4 7 8

2 2 2 2 2 2 3 3 3 3 4 1

t a b c d e f s vertex ordering: a, b, c, d, e, f, s, t cut-of-the-phase: {1}, {2, 3, 4, 5, 6, 7, 8} ω = 5

slide-24
SLIDE 24

The Algorithm Correctness Running Time

After the 2nd MinimumCutPhase(G, ω, a), a = 2

1,5 2 6 3 4 7 8

4 2 2 2 2 3 3 3 4 1

a d e s t c b vertex ordering: a, b, c, d, e, s, t cut-of-the-phase: {8}, {1, 2, 3, 4, 5, 6, 7} ω = 5

slide-25
SLIDE 25

The Algorithm Correctness Running Time

After the 3rd MinimumCutPhase(G, ω, a), a = 2

1,5 2 6 3 4 7,8

4 2 2 4 3 3 4 1

a d s t c b vertex ordering: a, b, c, d, s, t cut-of-the-phase: {7, 8}, {1, 2, 3, 4, 5, 6} ω = 7

slide-26
SLIDE 26

The Algorithm Correctness Running Time

After the 4th MinimumCutPhase(G, ω, a), a = 2

1,5 2 6 3

4, 7,8 4 2 6 3 3 1

a s t c b vertex ordering: a, b, c, s, t cut-of-the-phase: {4, 7, 8}, {1, 2, 3, 5, 6} ω = 7

slide-27
SLIDE 27

The Algorithm Correctness Running Time

After the 5th MinimumCutPhase(G, ω, a), a = 2

1,5 2 6

3,4, 7,8 4 2 3 3

a t s b

1

vertex ordering: a, b, s, t cut-of-the-phase: {3, 4, 7, 8}, {1, 2, 5, 6} ω = 4

slide-28
SLIDE 28

The Algorithm Correctness Running Time

After the 6th MinimumCutPhase(G, ω, a), a = 2

1,5 2

3,4,6 7,8 4 5 3

a s t vertex ordering: a, s, t cut-of-the-phase: {1, 5}, {2, 3, 4, 6, 7, 8} ω = 7

slide-29
SLIDE 29

The Algorithm Correctness Running Time

After the 7th MinimumCutPhase(G, ω, a), a = 2

2

V\{2}

9

s t vertex ordering: s, t cut-of-the-phase: {2}, {1, 3, 4, 5, 6, 7, 8} ω = 9

slide-30
SLIDE 30

The Algorithm Correctness Running Time

Cut-of-the-phase

cut-of-the-phase ω {1}; {2, 3, 4, 5, 6, 7, 8} 5 {8}; {1, 2, 3, 4, 5, 6, 7} 5 {7, 8}; {1, 2, 3, 4, 5, 6} 7 {4, 7, 8}; {1, 2, 3, 5, 6} 7 {3, 4, 7, 8}; {1, 2, 5, 6} 4 {1, 5}; {2, 3, 4, 6, 7, 8} 7 {2}; {1, 3, 4, 5, 6, 7, 8} 9

slide-31
SLIDE 31

The Algorithm Correctness Running Time

The Minimum Cut of the Graph G

1,5 2 6

3,4, 7,8 4 2 3 3

a t s b

1

vertex ordering: a, b, s, t cut-of-the-phase: {3, 4, 7, 8}, {1, 2, 5, 6} ω = 4

slide-32
SLIDE 32

The Algorithm Correctness Running Time

Outline

The Algorithm Global Minimum Cut Stoer-Wagner Algorithm Correctness Lemma & Theorem Proof Running Time Proof

slide-33
SLIDE 33

The Algorithm Correctness Running Time

Lemma

Each cut-of-the-phase is a minimum s-t cut in the current graph, where s and t are the two vertices added last in the phase.

Theorem

The lightest of these cuts-of-the-phase is the minimum cut of G. Assuming that the lemma holds, the theorem can be proved by a simple case distinction. Thus our proof is focused on the claimed property of the cut-of-the-phase.

slide-34
SLIDE 34

The Algorithm Correctness Running Time

Outline

The Algorithm Global Minimum Cut Stoer-Wagner Algorithm Correctness Lemma & Theorem Proof Running Time Proof

slide-35
SLIDE 35

The Algorithm Correctness Running Time

Proof

slide-36
SLIDE 36

The Algorithm Correctness Running Time

Definition

We call a vertex v active when v and the vertex added just before v are in different parts of the cut. a v w t T S active vertices: a, . . . , v, w, . . . , t

slide-37
SLIDE 37

The Algorithm Correctness Running Time

Proof

slide-38
SLIDE 38

The Algorithm Correctness Running Time

Proof

slide-39
SLIDE 39

The Algorithm Correctness Running Time

Proof

slide-40
SLIDE 40

The Algorithm Correctness Running Time

Proof

slide-41
SLIDE 41

The Algorithm Correctness Running Time

Proof

slide-42
SLIDE 42

The Algorithm Correctness Running Time

Outline

The Algorithm Global Minimum Cut Stoer-Wagner Algorithm Correctness Lemma & Theorem Proof Running Time Proof

slide-43
SLIDE 43

The Algorithm Correctness Running Time

MinimumCut Algorithm

MinimumCut(G, w, a)

1 while (| V |> 1) do 2

MinimumCutPhase(G, w, a)

3

if the cut-of-the-phase is lighter than the current minimum cut then

4

store the cut-of-the-phase as the current minimum cut

5

end

6 end

slide-44
SLIDE 44

The Algorithm Correctness Running Time

MinimumCutPhase Algorithm

MinimumCutPhase(G, w, a)

1 A {a} 2 while (A 6= V) do 3

add to A the most tightly connected vertex

4 end 5 store the cut-of-the-phase 6 shrink G by merging the two vertices added last

slide-45
SLIDE 45

The Algorithm Correctness Running Time

MinimumCutPhase Algorithm

MinimumCutPhase(G, w, a)

1 A {a} 2 while (A 6= V) do 3

add to A the most tightly connected vertex

4 end 5 store the cut-of-the-phase 6 shrink G by merging the two vertices added last

slide-46
SLIDE 46

The Algorithm Correctness Running Time

Proposition

The running time for a single phase is O(|E| + |V| log |V|).

Proof.

  • 1. All vertices that are not in A reside in a priority queue.
slide-47
SLIDE 47

The Algorithm Correctness Running Time

Proposition

The running time for a single phase is O(|E| + |V| log |V|).

Proof.

  • 1. All vertices that are not in A reside in a priority queue.
  • 2. Whenever a vertex v is added to A,

the priority queue does ExtractMax and IncreaseKey operations.

slide-48
SLIDE 48

The Algorithm Correctness Running Time

Proposition

The running time for a single phase is O(|E| + |V| log |V|).

Proof.

  • 1. All vertices that are not in A reside in a priority queue.
  • 2. Whenever a vertex v is added to A,

the priority queue does ExtractMax and IncreaseKey operations.

  • 3. |V| ExtractMax

|E| IncreaseKey

slide-49
SLIDE 49

The Algorithm Correctness Running Time

Proposition

The running time for a single phase is O(|E| + |V| log |V|).

Proof.

  • 1. All vertices that are not in A reside in a priority queue.
  • 2. Whenever a vertex v is added to A,

the priority queue does ExtractMax and IncreaseKey operations.

  • 3. |V| ExtractMax

|E| IncreaseKey

  • 4. Fibonacci heaps

ExtractMax O(log |V|) IncreaseKey O(1) Time for one phase is O(|E| + |V| log |V|).

slide-50
SLIDE 50

The Algorithm Correctness Running Time

Proposition

The overall running time of Stoer-Wagner algorithm for minimum cut in undirected graphs is O(|V||E| + |V|2 log |V|).

Proof.

  • 1. |V| 1 phases
  • 2. Time for single phase O(|E| + |V| log |V|)
  • 3. Overall running time O(|V||E| + |V|2 log |V|)
slide-51
SLIDE 51

The Algorithm Correctness Running Time

Thank you!

Q & A