Class SingleLinkageClusterer


  • public class SingleLinkageClusterer
    extends Object
    An implementation of a single linkage clusterer See http://en.wikipedia.org/wiki/Single-linkage_clustering
    Author:
    Jose Duarte
    • Constructor Detail

      • SingleLinkageClusterer

        public SingleLinkageClusterer​(double[][] matrix,
                                      boolean isScoreMatrix)
        Constructs a new SingleLinkageClusterer Subsequently use getDendrogram() to get the full tree or getClusters(double) to get the clusters at a certain cutoff in the tree Please note that the matrix will be altered during the clustering procedure. A copy must be made before by the user if needing to use the original matrix further.
        Parameters:
        matrix - the distance matrix with distance values in j>i half, all other values will be ignored
        isScoreMatrix - if false the matrix will be considered a distance matrix: lower values (distances) mean closer objects, if true the matrix will be considered a score matrix: larger values (scores) mean closer objects
        Throws:
        IllegalArgumentException - if matrix not square
    • Method Detail

      • getDendrogram

        public org.biojava.nbio.core.util.SingleLinkageClusterer.LinkedPair[] getDendrogram()
        Get the full dendrogram (size n-1) result of the hierarchical clustering
        Returns:
      • getClusters

        public Map<Integer,​Set<Integer>> getClusters​(double cutoff)
        Get the clusters by cutting the dendrogram at given cutoff
        Parameters:
        cutoff -
        Returns:
        Map from cluster numbers to indices of the cluster members