Louvain modularity optimization: Q = Σᵢⱼ [Aᵢⱼ − γ kᵢkⱼ/2m] δ(cᵢ,cⱼ). Communities maximize within-group edges vs random expectation. The resolution parameter γ controls the scale: large γ finds many small communities (less resolution limit). NMI measures agreement with ground truth.