Practice Prim's algorithm to find minimum spanning tree.