Implementation of Disjoint-set data structure algorithm (also called a union–find data structure or merge–find set).