Package com.chemaxon.clustering.common
Class IDBasedClusterBuilder
java.lang.Object
com.chemaxon.clustering.common.IDBasedClusterBuilder
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Allocate a new cluster.void
addStructuresToCluster
(Collection<Integer> structureIDs, int clusterID) Add multiple structures to a cluster.void
addStructureToCluster
(int structureID, int clusterID) Set a structure to be a part of a cluster as a leaf.build()
Build immutable clustering representation.boolean
isRepresentantSet
(int clusterId) Check if cluster representant is set.void
removeStructure
(int structureID) Remove a structure from its respective cluster.static String
toDetailedString
(IDBasedSingleLevelClustering clustering) Utility method to create a detailed string representation of a clustering.void
updateRepresentant
(int structureID, int clusterID) Set/update the cluster representant structure.
-
Constructor Details
-
IDBasedClusterBuilder
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 representantclusterID
- 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 addclusterID
- ID of the cluster of the structure- Throws:
IllegalStateException
- when structure is already a member of any other cluster
-
addStructuresToCluster
Add multiple structures to a cluster.- Parameters:
structureIDs
- Structure IDs to addclusterID
- 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
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
-