Minimum Spanning Tree Demonstration
This is a step through of an exam style question demonstrating the use of both Prim's and Kruskal's algorithms. Prim or Kruskal is selected with the slider. Decide on each step and use the vertical slider to check your answers as you go. The whole sequence can be run as an animation.
Kruskal's algorithm is a minimum-spanning-tree algorithm which finds an edge of the least possible weight that connects any two trees in the forest. It is a greedy algorithm in graph theory as it finds a minimum spanning tree for a connected weighted graph adding increasing cost arcs at each step. Prim's algorithm was developed in 1930 by Czech mathematician Vojtěch Jarník and later rediscovered and republished by computer scientists Robert C. Prim in 1957 and Edsger W. Dijkstra in 1959. Therefore, it is also sometimes called the DJP algorithm, Jarník's algorithm, the Prim–Jarník algorithm, or the Prim–Dijkstra algorithm.