meanap.pipeline.louvain¶
Louvain modularity optimization, port of community_louvain.m (BCT).
Single-run community detection. Inherently stochastic (random node
processing order each pass) — used as the building block for
modularity.py’s consensus-clustering wrapper, which stabilizes the
randomness across many runs. Not bit-reproducible against MATLAB (different
RNG stream) — see modularity.py’s module docstring.
Functions
|
Returns (M, Q): community affiliation vector (1-indexed, like MATLAB) and modularity. |
- meanap.pipeline.louvain.community_louvain(w, gamma=1.0, rng=None)[source]¶
Returns (M, Q): community affiliation vector (1-indexed, like MATLAB) and modularity.
Direct port of
community_louvain.m’s default (‘modularity’) path with no initial partition — matches howmod_consensus_cluster_iterate.malways calls it (community_louvain(adjM), no extra args). Renumbering of module labels happens exactly once per hierarchical level, after the local-moving phase fully converges — matching MATLAB’s structure, not after every node sweep.- Parameters:
w (ndarray)
gamma (float)
rng (Generator | None)
- Return type:
tuple[ndarray, float]