UnionFind

UnionFind

Union-find data structure.

Constructor

new UnionFind() → {UnionFind}

Source:
Parameters:
Name Type Description
... Any

this structure will be initialized with the discrete partition on the given set of elements.

Returns:
Type:
UnionFind
  • UnionFind struct

Methods

(static) get(object) → {String}

Find and return the name of the set containing the object.

Source:
Parameters:
Name Type Description
object Any
Returns:
Type:
String

(static) groups() → {Iterator}

Iterates over the sets stored in this structure.

Source:
Returns:
Type:
Iterator
Example
partition = UnionFind( 1, 2, 3 )
partition.groups() --> [ 1 ], [ 2 ], [ 3 ]
partition.union( 1, 2 )
partition.groups() --> [ 1, 2 ], [ 3 ]

(static) union()

Find the sets containing the objects and merge them all.

Source:
Parameters:
Name Type Description
... Any

objects