Class UnionFindSet<E>

java.lang.Object
pascal.taie.util.collection.UnionFindSet<E>

public class UnionFindSet<E> extends Object
  • Constructor Details

    • UnionFindSet

      public UnionFindSet(Collection<E> elems)
  • Method Details

    • union

      public boolean union(E e1, E e2)
      Unions the sets which e1 and e2 belong to, respectively.
      Returns:
      true if this union-find set changed as a result of this call.
    • isConnected

      public boolean isConnected(E e1, E e2)
      Returns:
      true if e1 and e2 belong to the same set.
    • findRoot

      public E findRoot(E e)
      Returns:
      the root element of the set which e belongs to.
    • numberOfSets

      public int numberOfSets()
      Returns:
      number of disjoint sets in this union-find set.
    • getDisjointSets

      public Collection<Set<E>> getDisjointSets()
      Returns:
      a collection of all disjoint sets in this union-find set.