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




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.




key :: !Item

Element used as key.

more :: [Item]

Other elements in the cluster.

size :: !Int

At least one, the key.

type Item = KeySource

An element of a cluster.

data DistMatrix s d Source

A distance matrix.




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

type ClusterDistance dSource


 = 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.