Undirected graph added in Prim algorithm