Implement Prim's algorithm to find the total weight of a minimum spanning tree.
Constraints
Example
>>> mst_weight(3, [(0,1,4),(1,2,5),(0,2,6)]) 9 >>> mst_weight(4, [(0,1,10),(0,2,6),(0,3,5),(1,3,15),(2,3,4)]) 19
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints