public class NodeUnionFind extends NodeIdAccessor
Nodes.
All operations have an accumulated worst-case complexity of O(a(n)), where a(n) is the inverse of
the Ackermann function A(n,n).| Modifier and Type | Field and Description |
|---|---|
private int[] |
parent |
private int[] |
rank |
epoch, graph| Constructor and Description |
|---|
NodeUnionFind(Graph graph)
Create a new union-find data structure for a
Graph. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equiv(Node a,
Node b) |
private int |
find(int a) |
Node |
find(Node a)
Get a representative element of the equivalence set of a node.
|
private void |
union(int a,
int b) |
void |
union(Node a,
Node b)
Merge the equivalence sets of two nodes.
|
getGraph, getNodeId, verifyIdsAreStablepublic NodeUnionFind(Graph graph)
Graph. Initially, all nodes are in their
own equivalence set.public void union(Node a, Node b)
public Node find(Node a)
private void union(int a, int b)
private int find(int a)