Added UnionFind interface to represent the API.