Package ffx.numerics.clustering
Class HierarchyBuilder
java.lang.Object
ffx.numerics.clustering.HierarchyBuilder
Performs agglomerative steps to build a clustering hierarchy from an initial set
of singleton clusters and a map of pairwise distances.
- Since:
- 1.0
- Author:
- Lars Behnke, 2013, Michael J. Schnieders
-
Constructor Summary
ConstructorsConstructorDescriptionHierarchyBuilder
(List<Cluster> clusters, DistanceMap distances) Constructs a HierarchyBuilder with an initial set of clusters and inter-cluster distances. -
Method Summary
Modifier and TypeMethodDescriptionvoid
agglomerate
(LinkageStrategy linkageStrategy) Performs one agglomerative step by merging the two closest clusters and updating linkages.flatAgg
(LinkageStrategy linkageStrategy, Double threshold) Performs agglomeration until the minimal inter-cluster distance exceeds the threshold, and returns the remaining clusters (flat clustering at that cut).Returns the current working list of clusters (not necessarily a single root).Gets the DistanceMap used to track inter-cluster distances during agglomeration.Returns the root cluster if the hierarchy is complete.boolean
Returns true if only a single cluster remains (i.e., the hierarchy has a root).
-
Constructor Details
-
HierarchyBuilder
Constructs a HierarchyBuilder with an initial set of clusters and inter-cluster distances.- Parameters:
clusters
- initial clusters (typically singletons)distances
- map of inter-cluster distances
-
-
Method Details
-
getDistances
Gets the DistanceMap used to track inter-cluster distances during agglomeration.- Returns:
- the DistanceMap backing this builder
-
getClusters
Returns the current working list of clusters (not necessarily a single root).- Returns:
- the list of current clusters
-
flatAgg
Performs agglomeration until the minimal inter-cluster distance exceeds the threshold, and returns the remaining clusters (flat clustering at that cut).- Parameters:
linkageStrategy
- linkage strategy to compute inter-cluster distancesthreshold
- maximum allowed linkage distance for merging- Returns:
- flat list of clusters remaining at the specified threshold
-
agglomerate
Performs one agglomerative step by merging the two closest clusters and updating linkages.- Parameters:
linkageStrategy
- strategy to compute new distances to the merged cluster
-
isTreeComplete
public boolean isTreeComplete()Returns true if only a single cluster remains (i.e., the hierarchy has a root).- Returns:
- true if a single root cluster remains; false otherwise
-
getRootCluster
Returns the root cluster if the hierarchy is complete.- Returns:
- the single remaining root cluster
- Throws:
RuntimeException
- if the tree is not complete
-