Correct kruskal algorithm.