15.082 and 6.855j spanning tree algorithms. 2 the greedy algorithm in action 1 2 3 4 5 6 7 35 10 30...

Post on 27-Mar-2015

214 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

15.082 and 6.855J

Spanning Tree Algorithms

2

The Greedy Algorithm in Action

1

2

3

4

5

6

7

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

3

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

4

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

5

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

6

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

7

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

8

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

9

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

10

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

11

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

12

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

13

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

14

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

Node 1 2 3 4 5 6 7

First 1 2 3 4 5 4 7

35

10

30

15

25

40

20 17

8

15

11

211

2

3 5 7

root node

4 66

15

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

Node 1 2 3 4 5 6 7

First 1 4 3 4 5 4 7

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

7

2

16

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

Node 1 2 3 4 5 6 7

First 1 4 3 4 5 4 5

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

77

17

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

Node 1 2 3 4 5 6 7

First 1 4 5 4 5 4 5

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

773

18

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

Node 1 2 3 4 5 6 7

First 1 4 4 4 4 4 4

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

75 73 5 73

19

The Greedy Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

Node 1 2 3 4 5 6 7

First 4 4 4 4 4 4 4

35

10

30

15

25

40

20 17

8

15

11

211

2

3

4

5

6

75 73

1

20

21

Prim’s Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

1121

4

5

6

7

1

2

3

The minimum cost arc from yellow nodes to green nodes can be found by placing arc values in a priority queue.

22

Prim’s Algorithm in Action

1

3

354

5

30

15

25

40

20

6

7

17

8

15

1121

4

5

6

7

1

3522

10

25

102

3

23

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

5

6

73

4

24

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

68

17

15

5 73

64

25

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

68

17

1564

15

515

1173 5

26

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

68

17

1564

15

515

1173 5

27

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

68

17

1564

15

515

113 75

117

28

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

68

17

1564

15

515

117

1173 5153

29

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

68

17

1564

15

515

117

1173 5153

30

20

Prim’s Algorithm in Action

1

3

354

515

25

40

6

7

17

15

11

1

3522

10

25

102 4

10 8

2130

8

20 3021

68

17

1564

15

515

117

1173 5153

31

Sollin’s Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

11

21

Treat all nodes as singleton components, and then select the min cost arc leaving the component.

4

5

6

7

1

2

3

4

5

6

7

1

2

3

32

Sollin’s Algorithm in Action

1

2

3

35

104

5

30

15

25

40

20

6

7

17

8

15

11

21

Find the min cost edge out of each component

4

5

6

7

1

2

3 73 5

6

top related