Implementation of Kruskal's algorithm in Java.