Implemented Prim's Algorithm