Implemented Kruskal's algorithm for WeightedGraph