minimum spanning trees kun-mao chao ( 趙坤茂 ) department of computer science and information...

17
Minimum Spanning Trees Kun-Mao Chao ( 趙趙趙 ) Department of Computer Scienc e and Information Engineering National Taiwan University, T aiwan E-mail: [email protected] WWW: http://www.csie.ntu.edu.tw/~k mchao

Post on 18-Dec-2015

259 views

Category:

Documents


0 download

TRANSCRIPT

Minimum Spanning Trees

Kun-Mao Chao (趙坤茂 )Department of Computer Science an

d Information EngineeringNational Taiwan University, Taiwan

E-mail: [email protected]

WWW: http://www.csie.ntu.edu.tw/~kmchao

2

Minimum Spanning Trees

• A minimum spanning tree (MST) of a weighted graph G is a spanning tree of G whose edges sum to minimum weight.

• In other words, a minimum spanning tree is a tree formed from a subset of the edges in a given undirected graph, with two properties:– it spans the graph, i.e., it includes every vertex in the

graph, and– it is a minimum, i.e., the total weight of all the edges is

as low as possible.

3

Minimum Spanning Trees

The minimum spanning tree problem is always included in algorithm textbooks since

• it arises in many applications, • it is an important example where greedy

algorithms always deliver an optimal solution, and• clever data structures are necessary to make it

work efficiently.

4

Its minimum spanning trees?

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

5

Some of its minimum spanning trees

4 3

1

12

1

2

a b c

d

e f

g h

4 3

1

1

1

2

a b c

d

e f

g h

2

4 3

1

1

1

2

a b c

d

e f

g h

2

4 3

1

2

1 1

2

a b c

d

e f

g h

6

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(a) (b)

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

(g, h)

2

(c)

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

(g, h)

2(a, b, c, d, e, f, g, h)

(d)

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(e)

Bor\r{u}vka's Algorithm

(1926)

7

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(a) (d, e) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(b) (g, h) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(c) (e, f) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(d) (b, d) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(e) (e, g) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(f) (b, c) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(g) (a, b) is added.

4 3

1

12

1

2

a b c

d

e f

g h

(h) A minimum spanning tree.

Kruskal's Algorithm

(1956)

8

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(a) (a, b) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(b) (b, d) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(c) (d, e) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(d) (d, f) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(e) (f, h) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(f) (g, h) is added.

4 3

4

1

1

5

2

1 1

2

a b c

d

e f

g h

2

(g) (b, c) is added.

4 3

1

1 1

2

a b c

d

e f

g h

2

(h) A minimum spanning tree.

Prim’s Algorithm

(1957)

Approximation algorithms

10

NP-hard: the barrier

• Since Levin & Cook (1971) & Karp (1972), many important problems have been shown to be NP-hard.

• The life-cycle of a problem– Defined– NP-hard– Heuristic or for special data

11

Too hard to survive?

Life finds the ways– Approximation – Online – Distributed– New models

• Quantum computing• Bio-computing

12

Approximation algorithms

• Heuristic vs. approximation algorithms– Ensuring the worst-case quality

• The error ratio– Relative and Absolute

– A k-approximation: minimization: sol/opt<=k;maximization: opt/sol<=k

– The ratio is always >1

13

Polynomial time approximation scheme

• For any fixed k>0, it finds a (1+k)-approximation in polynomial time.– Usually (1/k) appears in the time complexity,

e.q. O(n/k), O(n1/k).– If (1/k) not in the exponent, FPTAS

14

An example – Minimum tour (MT)

• Starting at a node, find a tour of min distance traveling all nodes and back to the starting node.

10

15

8

3

2

5

2

6

10

15

A doubling tree algorithm

• Find a minimum spanning tree

• Output the Euler tour in the doubling tree of MST

10

15

8

3

2

5

2

6

10

10

15

8

3

2

5

2

6

10

16

The error ratio

• MST<=MT– MST is the minimum cost of any spanning tree.– A tour must contain a spanning tree since it is

connected.

• It is a 2-approximation

• Triangle inequality => 2-approximation for TSP (visiting each city only once) Why?

17

All exact science is dominated by theidea of approximation.

-- Bertrand Russell (1872 - 1970)