working version; completed Kruskal, UnionFind, parsing input