Prim's Algorithm Exercise