@graphty/algorithms
Version:
Graph algorithms library for browser environments implemented in TypeScript
42 lines • 1.65 kB
TypeScript
/**
* Label Propagation Algorithm for Community Detection
*
* A fast, near-linear time algorithm that detects communities by
* propagating labels through the network. Each node adopts the label
* that most of its neighbors have.
*
* Reference: Raghavan et al. (2007) "Near linear time algorithm to
* detect community structures in large-scale networks"
*/
export interface LabelPropagationOptions {
maxIterations?: number;
randomSeed?: number;
}
export interface LabelPropagationResult {
communities: Map<string, number>;
iterations: number;
converged: boolean;
}
/**
* Label Propagation Algorithm
* Each node adopts the most frequent label among its neighbors
*
* @param graph - Undirected graph (can be weighted)
* @param options - Algorithm options
* @returns Community assignments
*
* Time Complexity: O(m) per iteration, typically O(km) for k iterations
* Space Complexity: O(n)
*/
export declare function labelPropagation(graph: Map<string, Map<string, number>>, options?: LabelPropagationOptions): LabelPropagationResult;
/**
* Asynchronous Label Propagation
* Updates all nodes simultaneously (can lead to oscillations)
*/
export declare function labelPropagationAsync(graph: Map<string, Map<string, number>>, options?: LabelPropagationOptions): LabelPropagationResult;
/**
* Semi-supervised Label Propagation
* Some nodes have fixed labels that don't change
*/
export declare function labelPropagationSemiSupervised(graph: Map<string, Map<string, number>>, seedLabels: Map<string, number>, options?: LabelPropagationOptions): LabelPropagationResult;
//# sourceMappingURL=label-propagation.d.ts.map