UNPKG

@graphty/algorithms

Version:

Graph algorithms library for browser environments implemented in TypeScript

34 lines 1.15 kB
/** * Leiden Algorithm for Community Detection * * An improved version of the Louvain algorithm that guarantees * well-connected communities and provides better quality partitions. * * Reference: Traag, V.A., Waltman, L. & van Eck, N.J. (2019) * "From Louvain to Leiden: guaranteeing well-connected communities" */ import type { Graph } from "../../core/graph.js"; export interface LeidenOptions { resolution?: number; randomSeed?: number; maxIterations?: number; threshold?: number; } export interface LeidenResult { communities: Map<string, number>; modularity: number; iterations: number; } /** * Leiden algorithm for community detection * Improves upon Louvain by ensuring well-connected communities * * @param graph - Undirected weighted graph - accepts Graph class or Map representation * @param options - Algorithm options * @returns Community assignments and modularity * * Time Complexity: O(m) per iteration, typically O(m log m) total * Space Complexity: O(n + m) */ export declare function leiden(graph: Graph, options?: LeidenOptions): LeidenResult; //# sourceMappingURL=leiden.d.ts.map