- data Cluster = Cluster {}
- type Item = Key
- data DistMatrix s d = DM {}
- type ClusterDistance d = Cluster -> (Cluster, d) -> (Cluster, d) -> Cluster -> d
- fromDistance :: Ord d => (Item -> Item -> d) -> Item -> ST s (DistMatrix s d)
- findMin :: Ord d => DistMatrix s d -> ST s ((Cluster, Cluster), d)
- mergeClusters :: Ord d => ClusterDistance d -> DistMatrix s d -> (Cluster, Cluster) -> ST s Cluster
Documentation
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.
data DistMatrix s d Source
A distance matrix.
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.