Infomap Python documentation

Infomap is a network community-detection method that finds the modules that best compress the flow of a random walk on your network. Infomap optimizes the objective function called the map equation:

  • It models system-wide dynamics based on the system’s wiring. Link direction and weight steer the walk, so citation, transport, and information networks cluster by their real dynamics.

  • It finds hierarchical solutions with no tuning parameters. The number of nested levels is inferred directly from the data.

  • It spans a broad range of flow models: multilayer, memory, temporal, metadata, and bipartite networks, all through the same objective function.

A weighted example network partitioned by Infomap into four modules, nodes coloured by module and sized by flow

Quick start

pip install infomap
import networkx as nx
import infomap

graph = nx.karate_club_graph()
result = infomap.run(graph, seed=123, num_trials=20, silent=True)

print(result.num_top_modules, "modules")
print(result.modules())

Continue to Installation for the command-line tool and shell completion, or jump to Quick start for the smallest Python API examples.

Where to go

Concepts

What the map equation is and why it works: flow, codelength, and hierarchy, taught from the ground up.

Concepts
Working with Infomap

Build networks from your data, run Infomap, tune the options, and read and visualise the results.

Working with Infomap
Flow models & representations

Multilayer, memory, temporal, metadata, bipartite, and higher-order networks: the representations beyond a plain graph.

Flow models & representations
Workflows & integrations

Use Infomap with Scanpy and GraphRAG, and run it at scale on HPC schedulers.

Workflows & integrations
Robustness & reliability

Keep sparse or incompletely sampled networks from fragmenting into spurious modules with the regularized map equation.

Robustness & reliability

External resources