Disjoint set implementation.