Skip to content

@graphty/algorithms / index / teraHAC

Function: teraHAC() ​

teraHAC(s, options?): TeraHacResult

Defined in: indexed/terahac.ts:121

TeraHAC over a snapshot: agglomerative clustering that repeatedly merges the closest pair of clusters, with the same distances, merge order and tie-breaks as the legacy teraHAC -- but over node indices, so the result no longer depends on what the node ids are.

The linkage is kept per ordered cluster pair as an aggregate (minimum, maximum, sum of distances or sum of squared distances) and updated on each merge, instead of rescanning every member pair; the pairwise distances are integers, so the sums, and the means divided out of them, are exact. A pair's distance reads the aggregate in the orientation legacy reads it, which matters on a directed snapshot, and ties go to the pair legacy's stable sort puts first: two original nodes before any pair with a merged cluster, and among those the most recent merge last.

Weights are ignored (legacy counts hops). O(n^2) memory and O(n (n + m)) for the distances; the merging keeps each cluster's closest partner and rescans a row only when that partner merges.

Parameters ​

s ​

GraphSnapshot

The snapshot

options? ​

TeraHacOptions = {}

TeraHacOptions

Returns ​

TeraHacResult

The flat clustering and the dendrogram