Minimum spanning trees Minimum Connector Algorithms Kruskals algorithm
- Slides: 29
Minimum spanning trees
Minimum Connector Algorithms Kruskal’s algorithm 1. 2. 3. Select the shortest edge in a network Prim’s algorithm 1. Select any vertex 2. Select the shortest edge connected to that vertex 3. Select the shortest edge connected to any vertex already connected 4. Repeat step 3 until all vertices have been connected Select the next shortest edge which does not create a cycle Repeat step 2 until all vertices have been connected
Minimum Connector Algorithms NO CYCLES!
Example A cable company want to connect five villages to their network which currently extends to the market town of Avonford. What is the minimum length of cable needed? 5 Brinleigh Cornwell 3 4 6 8 8 Avonford 7 4 Fingley 5 2 Edan Donster
We model the situation as a network, then the problem is to find the minimum connector for the network 5 B C 3 4 6 8 8 A F 7 5 4 2 E D
Kruskal’s Algorithm B List the edges in order of size: 5 C 3 4 6 8 8 A D F 7 5 4 2 E ED AB AE CD BC EF CF AF BF CF 2 3 4 4 5 5 6 7 8 8
Kruskal’s Algorithm B Select the shortest edge in the network 5 C 3 4 6 8 ED 2 8 A D F 7 5 4 2 E
Kruskal’s Algorithm B 5 Select the next shortest edge which does not create a cycle C 3 4 6 8 ED 2 AB 3 8 A D F 7 5 4 2 E
Kruskal’s Algorithm B 5 Select the next shortest edge which does not create a cycle C 3 4 6 8 ED 2 AB 3 CD 4 (or AE 4) 8 A D F 7 5 4 2 E
Kruskal’s Algorithm B 5 Select the next shortest edge which does not create a cycle C 3 4 6 8 ED AB CD AE 8 A D F 7 5 4 2 E 2 3 4 4
Kruskal’s Algorithm B 5 Select the next shortest edge which does not create a cycle C 3 4 6 8 8 A D F 7 5 4 2 E ED AB CD AE BC EF 2 3 4 4 5 – forms a cycle 5
Kruskal’s Algorithm B All vertices have been connected. 5 C 3 4 6 8 The solution is 8 A D F 7 5 4 2 E ED AB CD AE EF 2 3 4 4 5 Total weight of tree: 18
Prim’s Algorithm Select any vertex B 5 A C 3 4 6 8 Select the shortest edge connected to that vertex 8 A D F 7 5 4 2 E AB 3
Prim’s Algorithm B 5 Select the shortest edge connected to any vertex already connected. C 3 6 8 AE 4 4 8 A D F 7 5 4 2 E
Prim’s Algorithm B 5 Select the shortest edge connected to any vertex already connected. C 3 6 8 ED 2 4 8 A D F 7 5 4 2 E
Prim’s Algorithm B 5 Select the shortest edge connected to any vertex already connected. C 3 6 8 DC 4 4 8 A D F 7 5 4 2 E
Prim’s Algorithm B 5 Select the shortest edge connected to any vertex already connected. C 3 6 8 EF 5 4 8 A D F 7 5 4 2 E
Prim’s Algorithm B All vertices have been connected. 5 C 3 4 6 8 The solution is 8 A D F 7 5 4 2 E AB 3 AE 4 ED 2 DC 4 EF 5 Total weight of tree: 18
Prim’s Algorithm All vertices have been connected. B C 3 The solution is 4 A D F 5 4 2 E AB 3 AE 4 ED 2 DC 4 EF 5 Total weight of tree: 18
Some points to note • Both algorithms will always give solutions with the same length. • They will usually select edges in a different order – you must show this in your workings. • Occasionally they will use different edges – this may happen when you have to choose between edges with the same length. In this case there is more than one minimum connector for the network.
3 B F
F 3 B 4 C
F 3 B 4 C
F 3 B 4 C 6 E
F 3 B G 4 6 C 6 E D
F 3 7 B 4 6 G C 6 E D
F 3 7 B 4 6 G C 6 E D 7 A
F 3 7 B 4 6 G C 6 E 7 A D Total Weight of Tree: 33
- Spanning trees
- Dijkstra's algorithm proof
- Minimum spanning tree weighted graph
- Minimum leaf spanning tree
- Minimum spanning tree
- Minimum spanning tree definition
- Minimum spanning tree
- Minimum cost spanning tree
- Minimum spanning tree
- Minimum spanning tree shortest path
- Minimum spanning tree
- Prim
- Subspaces and spanning sets
- Minimum spanning tree
- Minimum spanning tree
- Minimum spanning tree
- Spanning tree algorithm in computer networks
- Minor connector for mandibular distal extension
- Components of rpd and their functions
- Minimum connector problem
- Absolute maxima and local maxima
- Spanning tree definition
- Asus spanning tree protocol
- Marc bremer
- Veilig werken langs de weg toolbox
- Udld normal vs aggressive
- Boundary spanning adalah
- Non-deterministic algorithm
- Spanning tree
- Spanning tree