import type { MstEdge } from './minimum_spanning_tree'; /** * λ (lambda) is the inverse of the merge distance: dense structure persists to * high λ. This module operates purely on graph structures and is independent of * any estimator wrapper. */ export interface CondensedEdge { parent: number; /** Child cluster id (>= n_samples) or point index (< n_samples). */ child: number; /** λ at which the child leaves the parent (1 / merge distance). */ lambda_val: number; /** Population of the child (1 for points, cluster size for clusters). */ child_size: number; } export interface ClusterSelectionOptions { cluster_selection_method?: 'eom' | 'leaf'; cluster_selection_epsilon?: number; allow_single_cluster?: boolean; } export interface CondensedClustering { labels: number[]; probabilities: number[]; /** Most-persistent point index per cluster label. */ exemplar_indices: Map; } /** * @returns `n_samples - 1` rows `[left, right, distance, size]`, where `left` * and `right` are node ids (points `< n_samples`, merged clusters `>= * n_samples`) and `size` is the merged population. */ export declare function build_single_linkage(mst_edges: MstEdge[], n_samples: number): number[][]; /** * Components smaller than `min_cluster_size` are treated as points falling out * of their parent cluster rather than as distinct clusters; a split into two * sufficiently large children creates two new clusters, and a one-sided split * lets the surviving side continue under the same cluster id. */ export declare function build_condensation_tree(mst_edges: MstEdge[], n_samples: number, min_cluster_size: number): CondensedEdge[]; export declare function condense_hierarchy(hierarchy: number[][], n_samples: number, min_cluster_size: number): CondensedEdge[]; /** * Computes per-cluster stability: `Σ (λ_child - λ_birth(cluster)) * child_size` * over all rows whose parent is the cluster. */ export declare function compute_stability(tree: CondensedEdge[], n_samples: number): Map; /** * `'eom'` (Excess of Mass) keeps a cluster when its own stability exceeds the * summed stability of its selected descendants; `'leaf'` keeps every leaf * cluster. `cluster_selection_epsilon` then merges clusters whose birth distance * (`1 / birth_lambda`) is below `epsilon` into a coarser ancestor. */ export declare function excess_of_mass(tree: CondensedEdge[], n_samples: number, options?: ClusterSelectionOptions): Set; /** * Points are routed to the lowest selected ancestor of the cluster they fall * out of; points with no selected ancestor are noise (`-1`). */ export declare function extract_labels(tree: CondensedEdge[], selected: Set, n_samples: number, allow_single_cluster?: boolean): CondensedClustering;