Class DisjointSets

java.lang.Object
org.locationtech.jts.operation.union.DisjointSets

public class DisjointSets extends Object
A data structure that represents a partition of a set into disjoint subsets, and allows merging subsets. Set items are represented by integer indices. Initially each item is in its own subset. Client code can merge subsets of items as required for the algorithm being performed (e.g. set partitioning or clustering). The current partitioning can be computed at any time, and subset items accessed by their indices. See the Wikipedia article on disjointiset data structures.
Author:
mdavis
  • Constructor Details

    • DisjointSets

      public DisjointSets(int size)
      Creates a new structure containing a given number of items.
      Parameters:
      size - the number of items contained in the set
  • Method Details

    • isSameSubset

      public boolean isSameSubset(int i, int j)
    • merge

      public void merge(int i, int j)
    • subsets

      public DisjointSets.Subsets subsets()