import { Graph } from '../graph/graph'; import { ClusteringError, ClusterMetrics, LeidenCommunity } from '../types/clustering-types'; import { Edge, Node } from '../types/graph'; import { Result } from '../types/result'; import { WeightFunction } from '../types/weight-function'; /** * Detect communities using the Leiden algorithm. * * The Leiden algorithm improves upon Louvain by adding a refinement phase that * guarantees all detected communities are connected subgraphs. * @template N - Node type * @template E - Edge type * @param graph - Input graph (directed or undirected) * @param options - Optional configuration * @param options.weightFn - Weight function for edges (default: all edges weight 1.0) * @param options.resolution - Resolution parameter (default: 1.0, higher values favor more communities) * @param options.maxIterations - Maximum iterations per phase (default: 100) * @returns Result with array of detected Leiden communities * @example * ```typescript * const graph = new Graph(true); * // ... add nodes and edges ... * * const result = leiden(graph); * if (result.ok) { * console.log(`Found ${result.value.communities.length} communities`); * result.value.communities.forEach((community) => { * console.log(`Community ${community.id}: ${community.nodes.size} nodes, connected: ${community.isConnected}`); * }); * } * ``` */ export declare const leiden: (graph: Graph, options?: { weightFn?: WeightFunction; resolution?: number; maxIterations?: number; }) => Result<{ communities: LeidenCommunity[]; metrics: ClusterMetrics; metadata: { algorithm: "leiden"; runtime: number; iterations: number; parameters: { resolution?: number; maxIterations?: number; }; }; }, ClusteringError>; //# sourceMappingURL=leiden.d.ts.map