Serial version of the disjoint set data structure