Skip to content

@graphty/algorithms / index / indexed / louvain

Function: louvain() ​

louvain(s, o?): LouvainResult

Defined in: indexed/louvain.ts:346

Louvain community detection over a snapshot: local moving to the best modularity gain, then collapse each community into a node and repeat, until a level stops paying for itself.

The legacy louvain switches implementation at 50 nodes (useOptimized) and its small-graph path has no aggregation phase at all, so this port is not move-for-move identical to either branch of it -- what it guarantees is a partition whose modularity is at least as high, measured by the same formula.

Parameters ​

s ​

GraphSnapshot

An undirected snapshot

o? ​

LouvainOptions = {}

Algorithm options

Returns ​

LouvainResult

The partition, its modularity, and the number of levels that improved it