init EdgeWeightGraph for Prim and Kruskal