Prim's algorithm with Adjacency matrix