rewrite kruskal.c