hierarchical-clustering-0.1: Algorithms for single, average/UPGMA and complete linkage clustering.

Data.Clustering.Hierarchical.Internal.DistanceMatrix

Synopsis

# Documentation

data Cluster Source

Internal (to this package) type used to represent a cluster (of possibly just one element). The `key` should be less than or equal to all `more` elements.

Constructors

 Cluster Fieldskey :: !ItemElement used as key. more :: [Item]Other elements in the cluster. size :: !IntAt least one, the `key`.

Instances

 Eq Cluster Ord Cluster Show Cluster

type Item = KeySource

An element of a cluster.

data DistMatrix s d Source

A distance matrix.

Constructors

 DM Fieldsmatrix :: STArray s (Item, Item) d active :: STRef s [Item] clusters :: STArray s Item Cluster

Arguments

 = Cluster Cluster A -> (Cluster, d) Cluster B1 and distance from A to B1 -> (Cluster, d) Cluster B2 and distance from A to B2 -> Cluster Cluster B = B1 U B2 -> d Distance from A to B.

Type for functions that calculate distances between clusters.

fromDistance :: Ord d => (Item -> Item -> d) -> Item -> ST s (DistMatrix s d)Source

O(n^2) Constructs a new distance matrix from a distance function and a number `n` of elements. Elements will be drawn from `[1..n]`

findMin :: Ord d => DistMatrix s d -> ST s ((Cluster, Cluster), d)Source

O(n^2) Returns the minimum distance of the distance matrix. The first key given is less than the second key.

mergeClusters :: Ord d => ClusterDistance d -> DistMatrix s d -> (Cluster, Cluster) -> ST s ClusterSource

O(n) Merges two clusters, returning the new cluster and the new distance matrix.