A efficient implementation of a disjoint-set datastructure