coins.backend.util
Class UnionFind

java.lang.Object
  extended bycoins.backend.util.UnionFind

public class UnionFind
extends java.lang.Object

Union-Find algorithm


Constructor Summary
UnionFind(int nelements)
          Create Union/Find data structure.
 
Method Summary
 int find(int x)
          Return the name of the set which x belongs to.
 boolean isEquiv(int x, int y)
          Return true if x and y are members of the same set.
 int union(int x, int y)
          Merge two sets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnionFind

public UnionFind(int nelements)
Create Union/Find data structure.

Method Detail

find

public int find(int x)
Return the name of the set which x belongs to.


union

public int union(int x,
                 int y)
Merge two sets


isEquiv

public boolean isEquiv(int x,
                       int y)
Return true if x and y are members of the same set.