@graphty/algorithms
Version:
Graph algorithms library for browser environments implemented in TypeScript
36 lines • 1.15 kB
TypeScript
import type { Graph } from "../core/graph.js";
import type { NodeId } from "../types/index.js";
/**
* Markov Clustering (MCL) algorithm implementation
*
* MCL simulates flow in graphs and finds clusters based on the notion that
* random walks stay within clusters and rarely move between clusters.
* The algorithm alternates between expansion (matrix squaring) and
* inflation (element-wise powering and normalization).
*
* Time complexity: O(V³) per iteration
* Space complexity: O(V²)
*/
export interface MCLOptions {
expansion?: number;
inflation?: number;
maxIterations?: number;
tolerance?: number;
pruningThreshold?: number;
selfLoops?: boolean;
}
export interface MCLResult {
communities: NodeId[][];
attractors: Set<NodeId>;
iterations: number;
converged: boolean;
}
/**
* Perform Markov Clustering on a graph
*/
export declare function markovClustering(graph: Graph, options?: MCLOptions): MCLResult;
/**
* Calculate modularity of MCL clustering result
*/
export declare function calculateMCLModularity(graph: Graph, communities: NodeId[][]): number;
//# sourceMappingURL=mcl.d.ts.map