Class IDBasedClusterBuilder

java.lang.Object
com.chemaxon.clustering.common.IDBasedClusterBuilder

@Beta @PublicAPI public final class IDBasedClusterBuilder extends Object
Builder for ID based non-hierarchic clustering.

The represented clustering have the following properties:

  • Cluster and structure IDs are nonnegative integers
  • All clusters are contained from 0 ID to the highest cluster ID ever added
  • No empty clusters allowed

Licensing: this class is part of the JKlustor suite; it can be used with valid JKlustor license.

Please note that this class is marked with @Beta annotation, so it can be subject of incompatible changes or removal in later releases.

  • Constructor Details

    • IDBasedClusterBuilder

      public IDBasedClusterBuilder() throws LicenseException
      Instantiate an empty builder.
      Throws:
      LicenseException - when appropriate license is not available
  • Method Details

    • addNewCluster

      public int addNewCluster()
      Allocate a new cluster.

      Note that it is not necessary to call this method; clusters are added implicitly.

      Returns:
      ID of a new empty cluster, considered as root.
    • updateRepresentant

      public void updateRepresentant(int structureID, int clusterID)
      Set/update the cluster representant structure.
      Parameters:
      structureID - Structure to pintpoint as representant
      clusterID - Associated cluster
    • isRepresentantSet

      public boolean isRepresentantSet(int clusterId)
      Check if cluster representant is set.
      Parameters:
      clusterId - Cluster ID
      Returns:
      true when cluster representant structure is set.
    • addStructureToCluster

      public void addStructureToCluster(int structureID, int clusterID)
      Set a structure to be a part of a cluster as a leaf.
      Parameters:
      structureID - ID of the structure to add
      clusterID - ID of the cluster of the structure
      Throws:
      IllegalStateException - when structure is already a member of any other cluster
    • addStructuresToCluster

      public void addStructuresToCluster(Collection<Integer> structureIDs, int clusterID)
      Add multiple structures to a cluster.
      Parameters:
      structureIDs - Structure IDs to add
      clusterID - ID of the immediate parent cluster for the structures
      Throws:
      IllegalStateException - when a structure is already a member of any other cluster
    • removeStructure

      public void removeStructure(int structureID)
      Remove a structure from its respective cluster.
      Parameters:
      structureID - ID of the structure to add
      Throws:
      IllegalStateException - when given structure is not a member of any cluster
    • toDetailedString

      public static String toDetailedString(IDBasedSingleLevelClustering clustering)
      Utility method to create a detailed string representation of a clustering.
      Parameters:
      clustering - Clustering to traverse
      Returns:
      Detailed multiline String representation
    • build

      Build immutable clustering representation.
      Returns:
      Immutable clustering representation