new DisjointSet()
DisjointSet utility with path compression. Some applications involve
grouping n distinct objects into a collection of disjoint sets. Two
important operations are then finding which set a given object belongs to
and uniting the two sets. A disjoint set data structure maintains a
collection S={ S1 , S2 ,..., Sk } of disjoint dynamic sets. Each set is
identified by a representative, which usually is a member in the set.
- Source:
Members
-
length :number
-
Holds the length of the internal set.
Type:
- number
- Source:
-
parent :Array.<number>
-
Holds the set containing the representative values.
Type:
- Array.<number>
- Source:
Methods
-
find(i) → {number}
-
Finds a pointer to the representative of the set containing i.
Parameters:
Name Type Description i
number - Source:
Returns:
The representative set of i.- Type
- number
-
union(i, j)
-
Unites two dynamic sets containing objects i and j, say Si and Sj, into a new set that Si ∪ Sj, assuming that Si ∩ Sj = ∅;
Parameters:
Name Type Description i
number j
number - Source: