Kruskal Algorithm implemented with union find