Getting the result of Prim's alg. as a tree