liveBook · Manning

Louvain algorithm

As explained in Domain-Specific Small Language Models

A community-detection algorithm that iteratively moves nodes and aggregates communities to improve a clustering objective.

A community-detection method that starts with each node alone, moves nodes between communities to improve a score, then aggregates the graph and repeats until improvement stops. section 14.1

Here it appears alongside GraphRAG indexing, where graph communities are computed after entities and relationships are merged into a NetworkX graph. section 14.1

Core steps shown here:

  • Begin from a singleton partition. section 14.1
  • Move nodes between communities to improve the quality score. section 14.1
  • Aggregate the resulting communities into a new network. section 14.1
  • Repeat until the score no longer improves. section 14.1

GraphRAG community detection

A knowledge graph is built from extracted entities and relationships, combined with NetworkX, then passed to the community routine before community summaries are generated.

How Domain-Specific Small Language Models covers it

How deep it goes
Defines the iterative move-and-aggregate procedure and notes the modularity-gain check, but stops short of a full formal proof.
Examples
Uses a combined knowledge graph, extracted entities and relationships, and later community summaries for querying.
What it assumes
Assumes a graph with nodes and edges, and introduces community assignment from scratch.
What you can do after
Operate graph clustering for downstream indexing by assigning nodes to communities and aggregating them iteratively.
How it connects
Connects to GraphRAG, NetworkX, modularity, Leiden algorithm, and community detection.

Also explained in

Compare how 3 books explain Louvain algorithm →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.