/** * A weighted undirected graph over string node ids. `edges` are undirected; a * repeated {a,b} pair (either orientation) accumulates weight. Self-loops * (a === b) are allowed and accounted for in the degree, which matters once * communities are aggregated into super-nodes. */ export interface WeightedGraph { /** The full node universe (may include nodes with no edges). */ nodes: string[]; edges: Array<{ a: string; b: string; weight: number; }>; } /** * A partition of a node universe: a map from node id to the id of the community * it belongs to. Community ids are themselves node ids (the lexicographically * smallest member acts as the stable representative). */ export type Partition = Map; /** * Default resolution ladder, coarse→fine. Higher resolution γ penalizes large * communities more, yielding more (smaller) communities — so the ladder walks * from few coarse subsystems to many fine ones. A boundary present at coarse γ * AND fine γ is scale-stable. Chosen as a geometric spread so each rung is a * distinct scale rather than a small perturbation of its neighbor. */ export declare const DEFAULT_RESOLUTIONS: readonly number[]; /** * Detect communities in a weighted graph at a single resolution γ via the * Louvain method: local-moving then aggregation, repeated until a level stops * improving. Returns a flat node→community partition (community ids are the * lexicographically smallest member). Deterministic for a given graph + γ. */ export declare function louvain(graph: WeightedGraph, resolution: number): Partition; /** * Score a partition with the resolution-parameterised modularity Q the * {@link louvain} local-moving phase optimises: * * Q = Σ_c [ Σ_in(c)/m − γ·(Σ_tot(c)/2m)² ] * * where Σ_in(c) is the intra-community edge weight (each undirected pair counted * once, self-loops once), Σ_tot(c) the summed degree of its members, and m the * graph mass. The convention is self-consistent rather than universal, and that * is what it is for: the ONE trivial partition (every node in one community) * scores exactly `1 − γ`, so comparing a candidate partition against the whole * needs no tuned constant — at the canonical γ = 1 the comparison is against 0. * * Deterministic: communities are accumulated in lexical id order, so the same * graph and partition always yield the same float. */ export declare function modularityOf(graph: WeightedGraph, partition: Partition, resolution: number): number; /** * Cluster the same graph at every resolution in the ladder, coarse→fine, and * return the partitions in ladder order. The multi-resolution family is the * input to scale-stability scoring (consensus.ts). Resolutions are applied in * the given order; the default ladder is {@link DEFAULT_RESOLUTIONS}. */ export declare function resolutionSweep(graph: WeightedGraph, resolutions?: readonly number[]): Partition[]; //# sourceMappingURL=modularity.d.ts.map