export type DistanceFunction = (pointA: number[], pointB: number[]) => number; export interface VectorPoint { id: string; vector: number[]; } /** * HDBSCAN (Hierarchical Density-Based Spatial Clustering of Applications with Noise) implementation * @template T - Type of data points, must include 'id' and 'vector' properties */ declare class HDBSCAN { private X; private allNearestNeighbors; private mpts; private coreDistances; private mrg; private mstEdges; private distanceFunction; private idToObject; /** * Creates a new HDBSCAN instance * @param X - Array of data points to cluster * @param mpts - Minimum points required to form a dense region (minimum cluster size) * @param distanceFunction - Optional function to calculate distance between points (defaults to cosine distance) */ constructor(X: T[], mpts: number, distanceFunction?: DistanceFunction); /** * Runs the HDBSCAN clustering algorithm * @returns Object containing clusters and outliers * @returns {T[][]} clusters - Array of clusters, where each cluster is an array of data points * @returns {T[]} outliers - Array of data points that don't belong to any cluster * @throws {Error} If an error occurs during clustering */ run(): { clusters: T[][]; outliers: T[]; }; private _computeAllNearestNeighbors; private _computeCoreDistances; private _constructMRG; private _computeMST; private _extractHDBSCANHierarchy; } export declare function euclidean(pointA: number[], pointB: number[]): number; export declare function manhattan(pointA: number[], pointB: number[]): number; export declare function cosine(pointA: number[], pointB: number[]): number; /** * Finds the n most central elements in a cluster of vectors * @template T Type of cluster elements extending {id: string; vector: number[]} * @param cluster Array of objects containing at least {id, vector} properties * @param n Number of central elements to return (must be >= 1) * @param distanceFunction Optional distance function (defaults to cosine) * @returns Array of input objects with additional distance property, representing the n most central elements, sorted by distance from centroid * @throws Error if n < 1 or cluster is empty */ export declare function findCentralElements(cluster: T[], n: number, distanceFunction?: DistanceFunction): (T & { distance: number; })[]; export default HDBSCAN;