Leiden algorithm
A community-detection algorithm for graphs: it partitions nodes into densely-connected groups (“communities”) by optimizing modularity, improving on the older Louvain method by guaranteeing well-connected communities and avoiding Louvain’s badly-connected/disconnected clusters. It is the clustering step the GraphRAG family runs on the extracted knowledge-graph.
Why GraphRAG uses it
GraphRAG picks Leiden specifically for its ability to recover hierarchical community structure of large graphs efficiently. That hierarchy is what gives GraphRAG its community levels C0 (root) → C3 (leaf): each level is a coarser-or-finer partition of the same graph, and summarizing communities at a chosen level trades detail against token cost (the C0 root level is the cheap, coarse end — see from-local-to-global-graphrag‘s 9×–43× cost finding).
Where it shows up here
- graphrag / from-local-to-global-graphrag — Leiden + community summaries answer global queries.
- graphrag-rs — pairs Leiden communities with PageRank ranking in its Rust pipeline.
- LeanRAG — its “semantic islands” critique is, in effect, that Leiden’s per-community summaries are left unconnected to one another unless you add explicit cross-summary relations.
Related
graphrag · from-local-to-global-graphrag · graphrag-rs · leanrag · knowledge-graph