Prim's MST algorithm