UNPKG

@graphty/algorithms

Version:

Graph algorithms library for browser environments implemented in TypeScript

28 lines 968 B
import type { Graph } from "../core/graph.js"; import type { NodeId } from "../types/index.js"; /** * Spectral Clustering implementation * * Uses eigenvalues and eigenvectors of the graph Laplacian matrix to perform clustering. * Particularly effective for finding non-convex clusters and communities in graphs. * * Time complexity: O(V³) for eigendecomposition * Space complexity: O(V²) */ export interface SpectralClusteringOptions { k: number; laplacianType?: "unnormalized" | "normalized" | "randomWalk"; maxIterations?: number; tolerance?: number; } export interface SpectralClusteringResult { communities: NodeId[][]; clusterAssignments: Map<NodeId, number>; eigenvalues?: number[]; eigenvectors?: number[][]; } /** * Perform spectral clustering on a graph */ export declare function spectralClustering(graph: Graph, options: SpectralClusteringOptions): SpectralClusteringResult; //# sourceMappingURL=spectral.d.ts.map