| 
 | JGraph X 2.1.0.7 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mxgraph.analysis.mxUnionFind
public class mxUnionFind
Implements a union find structure that uses union by rank and path
 compression. The union by rank guarantees worst case find time of O(log N),
 while Tarjan shows that in combination with path compression (halving) the
 average time for an arbitrary sequence of m >= n operations is
 O(m*alpha(m,n)), where alpha is the inverse of the Ackermann function,
 defined as follows:
 alpha(m,n) = min{i >= 1 | A(i, floor(m/n)) > log n} for m >= n >= 1
 Which yields almost constant time for each individual operation.
| Nested Class Summary | |
|---|---|
|  class | mxUnionFind.NodeA class that defines the identity of a set. | 
| Field Summary | |
|---|---|
| protected  Map<Object,mxUnionFind.Node> | nodesMaps from elements to nodes | 
| Constructor Summary | |
|---|---|
| mxUnionFind(Object[] elements)Constructs a union find structure and initializes it with the specified elements. | |
| Method Summary | |
|---|---|
|  boolean | differ(Object a,
       Object b)Returns true if element a and element b are not in the same set. | 
|  mxUnionFind.Node | find(mxUnionFind.Node node)Returns the set that contains node. | 
|  mxUnionFind.Node | getNode(Object element)Returns the node that represents element. | 
|  void | union(mxUnionFind.Node a,
      mxUnionFind.Node b)Unifies the sets aandbin constant time
 using a union by rank on the tree size. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected Map<Object,mxUnionFind.Node> nodes
| Constructor Detail | 
|---|
public mxUnionFind(Object[] elements)
elements - | Method Detail | 
|---|
public mxUnionFind.Node getNode(Object element)
public mxUnionFind.Node find(mxUnionFind.Node node)
node. This implementation
 provides path compression by halving.
public void union(mxUnionFind.Node a,
                  mxUnionFind.Node b)
a and b in constant time
 using a union by rank on the tree size.
public boolean differ(Object a,
                      Object b)
a - The first element to compare.b - The second element to compare.
getNode(Object)| 
 | JGraph X 2.1.0.7 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||