Class HierarchyBuilder

java.lang.Object
ffx.numerics.clustering.HierarchyBuilder

public class HierarchyBuilder extends Object
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 Details

    • HierarchyBuilder

      public HierarchyBuilder(List<Cluster> clusters, DistanceMap distances)
      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

      public DistanceMap getDistances()
      Gets the DistanceMap used to track inter-cluster distances during agglomeration.
      Returns:
      the DistanceMap backing this builder
    • getClusters

      public List<Cluster> getClusters()
      Returns the current working list of clusters (not necessarily a single root).
      Returns:
      the list of current clusters
    • flatAgg

      public List<Cluster> 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).
      Parameters:
      linkageStrategy - linkage strategy to compute inter-cluster distances
      threshold - maximum allowed linkage distance for merging
      Returns:
      flat list of clusters remaining at the specified threshold
    • agglomerate

      public void agglomerate(LinkageStrategy linkageStrategy)
      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

      public Cluster getRootCluster()
      Returns the root cluster if the hierarchy is complete.
      Returns:
      the single remaining root cluster
      Throws:
      RuntimeException - if the tree is not complete