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
| Parameter | Type | Default | Description |
|---|---|---|---|
resolution | float | 1.0 | Controls community size (higher = smaller communities) |
weight_prop | str | None | Edge 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
| Aspect | Louvain | Label Propagation |
|---|---|---|
| Quality | Higher modularity | Good, slightly lower |
| Speed | O(V log V) | O(V + E) - faster |
| Deterministic | No (random seed) | No (order dependent) |
| Best for | Quality matters | Speed critical |
Rule of thumb: Use Louvain for better quality, Label Propagation for massive graphs
Performance Tips
- Adjust resolution based on expected community size
- Use temporal windows for evolving networks
- Run multiple times with different seeds and compare
- Sample for exploration on huge graphs (>100M edges)
See Also
- Label Propagation - Faster community detection
- User Guide: Community Detection - Detailed guide