Multi-level Louvain maximizing the generalized modularity \(Q_\gamma = (1/2m)\sum_{ij}[A_{ij} - \gamma k_i k_j/2m]\delta(c_i, c_j)\): a local-moving phase (each node joins the neighbouring community with the largest strictly positive gain) alternates with an aggregation phase (each community contracts to one node carrying the internal weight as a self-loop) until a level no longer improves the quality. Deterministic: nodes are visited in index order, candidate communities in ascending label order, and moves need a strict gain, mirroring the Python arm exactly. gamma = 1 is plain Louvain.
Value
List with communities (0-based labels, matching the Python arm), estimate (final quality), n_communities, levels, modularity_by_level, n, resolution.
References
Blondel, V. D., Guillaume, J.-L., Lambiotte, R. and Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics, P10008, Sec. 2, arXiv:0803.0476.
Reichardt, J. and Bornholdt, S. (2006). Statistical mechanics of community detection. Physical Review E, 74, 016110.
Examples
blocks <- matrix(0, 6, 6)
blocks[1:3, 1:3] <- 1; blocks[4:6, 4:6] <- 1; diag(blocks) <- 0
blocks[3, 4] <- blocks[4, 3] <- 1
LuvR(blocks)
#> $communities
#> [1] 0 0 0 1 1 1
#>
#> $estimate
#> [1] 0.3571429
#>
#> $n_communities
#> [1] 2
#>
#> $levels
#> [1] 1
#>
#> $modularity_by_level
#> [1] 0.3571429
#>
#> $n
#> [1] 6
#>
#> $resolution
#> [1] 1
#>
#> $method
#> [1] "Louvain with resolution gamma (Blondel 2008 / Reichardt-Bornholdt 2006)"
#>
