Implemented mst using prim's algorithm (works on weighted graph)