Minimum Spanning Tree

Prim’s Algorithm

Like Kruskal’s Algorithm, Prim’s algorithm is a special case of the generic minimum-spanning-tree method. It operates much like Dijkstra’s Algorithm for finding shortest paths in a graph.

Tree starts from an arbitrary root vertex and grows until the tree spans all the vertices of . Each step adds

Prim's Algorithm vs. Kruskal's Algorithm

I’ve had the difficulty to decide which algorithm to use for solving a question for my Algorithm’s class. But decided to use Prim’s Algorithm instead to find the MST because there might be a lot of edges in the test cases. Apparently, it would be faster using Prim’s algorithm. Another reason was because Prim starts with the selecting a vertex, and traverse from adjacent vertex to another. Which I find more intuitive then starting from the smallest weighted edge? Maybe it doesn’t matter.

When should I use Kruskal as opposed to Prim (and vice versa)?

Difference between Prim’s and Kruskal’s algorithm for MST