Fix the Prim's MST algorithm