Newman's modularity Q for a weighted partition.
Q = (1 / 2m) Σ_{ij} [A_ij - k_i k_j / 2m] δ(c_i, c_j)
where A_ij is edge weight, k_i weighted degree, and δ the Kronecker indicator for same-community. Q ∈ [-0.5, 1]; values >0.3 indicate meaningful community structure.
A_ij
k_i
δ
[-0.5, 1]
Node universe.
Weighted edges.
Community label per node (from labelPropagation).
Modularity Q rounded to 4 decimal places (0 when the graph is empty).
0
Newman's modularity Q for a weighted partition.
Q = (1 / 2m) Σ_{ij} [A_ij - k_i k_j / 2m] δ(c_i, c_j)where
A_ijis edge weight,k_iweighted degree, andδthe Kronecker indicator for same-community. Q ∈[-0.5, 1]; values >0.3 indicate meaningful community structure.