Prim MST Algorithm

Therefore, it is also sometimes named the Jarník's algorithm, Prim – Jarník algorithm, Prim – Dijkstra algorithm or the DJP algorithm. However, for graphs that are sufficiently dense, Prim's algorithm can be made to work in linear time, meeting or better the time boundary for other algorithms.

Prim MST source code, pseudocode and analysis