public final class UnionFind extends Object implements IntDisjointSets
| Constructor and Description |
|---|
UnionFind(int n)
Initializes the disjoint-set data structure.
|
| Modifier and Type | Method and Description |
|---|---|
int |
find(int x)
Finds the set of a given element, and compresses the path to the root node.
|
int |
link(int x,
int y)
Unites two given sets.
|
int |
size()
Returns the size of the universe.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequivalent, unionpublic UnionFind(int n)
n - the overall size of the domainpublic int size()
IntDisjointSets0 (inclusive) and
size() (exclusive).size in interface IntDisjointSetspublic int find(int x)
find in interface IntDisjointSetsx - the elementpublic int link(int x,
int y)
link in interface IntDisjointSetsx - the first sety - the second setx or y)Copyright © 2020. All rights reserved.