Louvain Community Detection

Discover clusters and coordinated groups automatically

Louvain detects communities by optimizing modularity - groups of nodes with dense internal connections but sparse connections to other groups.

What It Computes

For each node, assigns a community ID (integer). Nodes in the same community are more densely connected to each other than to the rest of the network.

Key insight: Hierarchical approach finds communities at multiple scales, from small clusters to large groups.

When to Use It

✅ Fraud Detection

Find coordinated fraud rings and money laundering networks

✅ Customer Segmentation

Identify natural customer groups for targeted marketing

✅ Social Analysis

Detect friend groups, echo chambers, toxic communities

✅ Network Optimization

Partition networks for distributed processing

Parameters

ParameterTypeDefaultDescription
resolutionfloat1.0Controls community size (higher = smaller communities)
weight_propstrNoneEdge weight property name

Tuning advice:

  • resolution < 1.0: Larger, fewer communities
  • resolution > 1.0: Smaller, more communities
  • resolution = 1.0: Standard modularity optimization

Performance

Time Complexity: O(V log V)
Space Complexity: O(V + E)
Typical Runtime: 2-5 seconds for 1M edges

Scales to: 10M+ edges efficiently

Example

Output:

Real-World Use Cases

Fraud Ring Detection

Problem: Identify coordinated fraud groups
Solution: Louvain finds tightly connected accounts

Customer Segmentation

Problem: Group customers for targeted campaigns
Solution: Natural communities = customer segments

Social Network Moderation

Problem: Identify toxic communities early
Solution: Track community health metrics over time

Temporal Community Evolution

Track how communities form and evolve:

Use case: Detect emerging fraud networks, community splits, growing clusters

Comparison with Label Propagation

AspectLouvainLabel Propagation
QualityHigher modularityGood, slightly lower
SpeedO(V log V)O(V + E) - faster
DeterministicNo (random seed)No (order dependent)
Best forQuality mattersSpeed critical

Rule of thumb: Use Louvain for better quality, Label Propagation for massive graphs

Performance Tips

  1. Adjust resolution based on expected community size
  2. Use temporal windows for evolving networks
  3. Run multiple times with different seeds and compare
  4. Sample for exploration on huge graphs (>100M edges)

See Also