Skip to content
Graph Intelligence Hub
Menu

Algorithm

Leiden community detection

activeNeeds verification

Refinement of Louvain that guarantees well-connected communities and converges to better partitions; used for community summaries in Microsoft GraphRAG.

Definition

Intuition

Like Louvain, but adds a refinement phase that may split communities so every community stays internally connected.

Complexity

TimeNear-linear in E in practice
SpaceO(V + E)

Python

import igraph as ig
g = ig.Graph.Famous('Zachary')
part = g.community_leiden(objective_function='modularity')

Cypher (Neo4j GDS)

CALL gds.leiden.stream('myGraph')
YIELD nodeId, communityId RETURN communityId, count(*) AS size

Procedure names and options vary between GDS versions; check the GDS docs for your version.

An interactive step-by-step visualizer for this algorithm is planned for phase 3.

Profile

Time complexityNear-linear in E in practice
Space complexityO(V + E)

Relationships

Succeeds
Implemented by
Related