add WeightedUnionFind.java class which represents a union-find data structure.