Detect communities in a planted partition graph using modularity maximization (Louvain-style greedy). Watch how Q-modularity score increases as communities are merged. Compare planted vs detected communities.
Modularity Q = (1/2m)Σ_{ij}[A_{ij} - k_ik_j/2m]δ(c_i,c_j). Ranges from -0.5 to 1; Q>0.3 indicates significant community structure. Planted partition model: p_in = r·p_out with community size n/k. Detectability threshold: r_c = 1 + √(n/k) (Decelle et al. 2011 — cavity method). Below threshold: no algorithm can find communities better than random. Modularity maximization is NP-hard but Louvain greedy is O(m log m) in practice.