Minimum Spanning Tree

Undirected Weighted Graph

  • A undirected graph whose edges have weights.

Definition

1

2

3

4

  • Example:
  • \(V=\{1,2,3,4\}\)
  • \(E=\{\)
        \((1,3), (1,2),\)
        \((2,3), (4,2),\)
        \((3,4)\)
    \(\}\)
  • \(W\left(\left(1,2\right)\right)=13\)

2

8

13

7

6

$$G=(V,E)$$

  • \(V\) is a set of vertices of \(G\) and \(E\) is a set of edges of \(G\).
  • \(\forall e \in E\),
    we define the weight function \(W(e)\) is the weight of \(e\).

Spanning Tree

  • Give graph \(G=(V,E)\)
  • Spanning Tree is a connected tree \(T=(V,E')\) where
    $$E' \subseteq E$$

2

4

3

2

1

8

13

7

6

Minimum Spanning Tree(MST)

  • Give graph \(G=(V,E)\)
  • Minimum Spanning Tree is a Spanning Tree which
    the
    sum of edge weights is minimum.

2

6

7

13

8

4

3

2

1

Greedy Algorithms to find MST

  • Kruskal's algorithm
  • Prim's algorithm
  • Borůvka's algorithm
  • ...

Kruskal's algorithm

  • Input \(G=(V,E)\)
  • Let \(E_s = E,   E' = \{\}\)
  • while ( \(E_s\) is not empty)
    • Remove an edge \(e\) with minimum weight from \(E_s\)
    • If add \(e\) into \(E'\) will not create a circle
      • Add \(e\) into \(E'\)
  • If \(T=(V,E')\) is a tree
    • output \(T\) is a minimum spanning tree

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Kruskal's algorithm

6

7

13

8

2

4

3

2

1

Complexity

  • Sort the edges by weight
  • Using Union Find Set to maintain trees
O\left(E \log E + E \alpha\left(V\right)\right) = O(E \log E)

How
to
Proof?

Edge inclusion lemma

$$G=(V,E)$$

  • Let \(S\) be a subset of \(V\), and suppose \(e = (u, v)\) is the minimum cost edge of \(E\), with \(u\) in \(S\) and \(v\) in \(V-S\).
  •  Then \(e\) is in a certain minimum spanning tree of \(G\).

\(u\)

\(v\)

\(V-S\)

\(S\)

\(e\)

Proof

  • Suppose \(T\) is a minimum spanning tree that does not contain \(e\).

\(v\)

\(u\)

\(S\)

\(V-S\)

\(u'\)

\(v'\)

a

b

c

d

e

\(e\)

\(e'\)

Proof

  • Add \(e\) to \(T\), this creates a cycle.
  • The cycle must have some edge \(e' = (u', v')\) with \(u'\) in \(S\) and \(v'\) in \(V-S\).

\(v\)

\(u\)

\(S\)

\(V-S\)

\(u'\)

\(v'\)

a

b

c

d

e

\(e\)

\(e'\)

Proof

  • By definition, we have \(W(e) \le W(e')\)
  • \(W(e) = W(e')\) because \(T\) is a minimum spanning tree.

\(v\)

\(u\)

\(S\)

\(V-S\)

\(u'\)

\(v'\)

a

b

c

d

e

\(e\)

\(e'\)

Proof

  • By definition, we have \(W(e) \le W(e')\)
  • \(W(e) = W(e')\) because \(T\) is a minimum spanning tree.
  • We can remove \(e'\) and add \(e\) to create a new tree \(T'\)
  • \(T'\) must be a minimum spanning tree!

\(v\)

\(u\)

\(S\)

\(V-S\)

\(u'\)

\(v'\)

a

b

c

d

e

\(e\)

\(e'\)

Prim's algorithm

  • \(G=(V,E)\)
  • Let \(S=\{v_0\}\) where \(v_0 \in V\)
  • Let \(E'=\{\}\)
  • while(\(V-S\) not empty)
    • Let \(e = (u, v)\) is the minimum cost edge of \(E\), with \(u\) in \(S\) and \(v\) in \(V-S\)
    • Add \(e\) into \(E'\)
    • add \(v\) into \(S\)
  • If \(T=(V,E')\) is a tree
    • output \(T\) is a minimum spanning tree

Prim's algorithm

a

d

b

g

f

c

e

5

7

9

15

6

8

11

9

7

8

5

\(S = \{a\}\)

Prim's algorithm

a

d

b

g

f

c

e

5

7

9

15

6

8

11

9

7

8

5

\(S = \{a,d\}\)

Prim's algorithm

a

d

b

g

f

c

e

5

7

9

15

6

8

11

9

7

8

5

\(S = \{a,d,f\}\)

Prim's algorithm

a

d

b

g

f

c

e

5

7

9

15

6

8

11

9

7

8

5

\(S = \{a,d,f,b\}\)

Prim's algorithm

a

d

b

g

f

c

e

5

7

9

15

6

8

11

9

7

8

5

\(S = \{a,d,f,b,e\}\)

Prim's algorithm

a

d

b

g

f

c

e

5

7

9

15

6

8

11

9

7

8

5

\(S = \{a,d,f,b,e,c\}\)

Prim's algorithm

a

d

b

g

f

c

e

5

7

9

15

6

8

11

9

7

8

5

\(S = \{a,d,f,b,e,c,g\}\)

Complexity

  • Using Binary heap maintain edges
  • Using adjacency list
O\left(E\log V\right)

Complexity

  • Using Fibonacci heap maintain edges
  • Using adjacency list
O\left(E + V\log V\right)

UVa 908
Tioj 1211

Minimum Bottleneck Path

  • \(G=(V,E)\)

  • For any path \(p\), we call a \(Bottleneck(p)\)  is an edge \(e \in p\)
    which \(W(e)\) is maximum

  • A Minimum Bottleneck Path from \(u\) to \(v\)
    is a path \(p\) from \(u\) to \(v\) which \(W(Bottleneck(p))\) is minimum

Minimum Bottleneck Path

4

8

7

9

11

8

6

15

9

7

5

e

c

f

g

b

d

a

Minimum Bottleneck Path

4

8

7

9

11

8

6

15

9

7

5

e

c

f

g

b

d

a

Minimum Bottleneck Lemma

  • \(G=(V,E)\)
  • Let \(T=(V,E')\) is a Minimum Spanning Tree of \(G\)
  • \(\forall u,v \in V\):
    • \(path(u,v)\) in \(T\) is a Minimum Bottleneck Path in \(G\)

Proof

We ignore proof because it is similar to
Edge Inclusion lemma

UVa 10369
UVa 1395

Minimum Spanning Tree

By jacky860226

Minimum Spanning Tree

  • 436