// Agglomerative hierarchical clustering
eles.hierarchicalClustering(options?: HierarchicalClusteringOptions): AlgoRun<Collection<NodeData, EdgeData, NodeData>[]>Agglomerative hierarchical clustering. Async: returns a promise, and executor ('cpu' | 'gpu' | 'auto', default 'auto'; 'workers' runs the reference on one pool worker) picks where the distance matrix is built; the merge chain itself is sequential and runs with the reference — in-thread, or on the pool worker for a named distance and a 'min' / 'max' / 'mean' linkage. A custom distance function or a per-pair linkage consults the metric inside the run, on the calling thread, and 'workers' rejects them. Threshold mode merges every closest pair at most threshold apart, a merge at exactly threshold included, as SciPy's fcluster and R's cutree.
| Name | Description |
|---|---|
options: HierarchicalClusteringOptions? |
|
Fields of options
| Name | Description |
|---|---|
distance: DistanceMetric? | |
linkage: string? | linkage criterion: 'min' (single), 'max' (complete), 'mean', or per-pair |
mode: 'threshold' | 'dendrogram'? | |
threshold: number? | threshold mode merges pairs at most this far apart (default Infinity) |
addDendrogram: boolean? | |
dendrogramDepth: number? | |
attributes: HierarchicalAttributeFn[]? | |
executor: AlgoExecutor? | where the run executes; see |
AlgoRun<Collection<NodeData, EdgeData, NodeData>[]>a promise of one collection per cluster — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed
Example
const run = eles.hierarchicalClustering({ attributes: [node => node.data('score')], executor: 'cpu' });const result = await run;console.log(result.reduce((sum, cluster) => sum + cluster.length, 0)); // 3if executor is invalid; rejects if executor: 'gpu' is unavailable in this environment, or executor: 'workers' is given a custom distance function or a per-pair linkage
Also spelled eles.hca.