Prim's algorithm implementation to create the base solution.