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.
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¶
What the map equation is and why it works: flow, codelength, and hierarchy, taught from the ground up.
Build networks from your data, run Infomap, tune the options, and read and visualise the results.
Multilayer, memory, temporal, metadata, bipartite, and higher-order networks: the representations beyond a plain graph.
Use Infomap with Scanpy and GraphRAG, and run it at scale on HPC schedulers.
Keep sparse or incompletely sampled networks from fragmenting into spurious modules with the regularized map equation.
External resources¶
The Infomap user guide on mapequation.org is the project portal and documents the command-line tool and the other interfaces (C++, R, JavaScript).
GitHub repository for source, issues, and discussions.