Loading repovive.com/problems/classics/20
Given an undirected weighted graph with vertices and edges, find the weight of the Minimum Spanning Tree (MST) using Prim's algorithm.
Prim's algorithm starts from vertex 1 and greedily adds the minimum weight edge connecting the current tree to an unvisited vertex, using a priority queue.
If the graph is not connected, output -1.