Presentation is loading. Please wait.

Presentation is loading. Please wait.

Minimum Spanning Tree.

Similar presentations


Presentation on theme: "Minimum Spanning Tree."— Presentation transcript:

1 Minimum Spanning Tree

2 Minimum Spanning Tree Weight on edge; find set of edges that minimize connecting everything Kruskal’s algorithm: Sort edges from lowest weight to highest Add edges by doing a union-find set combination each Done when you have just one set (i.e. have added n-1 edges, thus joining all n vertices)

3 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

4 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

5 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

6 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

7 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

8 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

9 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

10 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

11 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

12 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

13 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

14 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

15 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

16 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

17 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

18 Minimum Spanning Tree Weight on edge; find set of edges that minimize connecting everything Prim’s algorithm: For each node, mark as “in” or “out”. Start with any node as the only one “in” Priority queue of edges, based on weight. Add the edges for the “in” node Repeatedly get next edge from queue. If one of the nodes is “out”, then: Mark that node “in” Add its edges to the priority queue.

19 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

20 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

21 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

22 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

23 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

24 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

25 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

26 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

27 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

28 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

29 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

30 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

31 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

32 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

33 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

34 10 9 21 17 14 7 6 8 3 11 9 15 4 1 5 19 16 2 20

35 MST variants Maximum spanning tree
Use Kruskal’s with edges sorted greatest to smallest Minimum spanning subgraph (some edges already included) Run Kruskal’s but with some stuff already merged Minimum forest (can have up to x components) Run Kruskal’s until just x sets Second-best tree Get MST, then try removing a link, and find first link to connect Repeat for all links Minimax – minimum of maximum edge weights along any path i to j Just a subset of the MST – path from i to j in the MST.


Download ppt "Minimum Spanning Tree."

Similar presentations


Ads by Google