Prim’s Algorithm IV