Clustering, density estimation, and anomaly detection · Graph and community clustering · UCL032 · Algorithm
Infomap
Detect communities by compressing a random walk on a graph. Groups are useful when a walker spends enough time inside them that a two-level coding scheme shortens the description of its path.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.
- Network communities Experimental
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
- Availability
- Runs in CodeSplash (Experimental)
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through discover.communities. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Detect communities by compressing a random walk on a graph. Groups are useful when a walker spends enough time inside them that a two-level coding scheme shortens the description of its path.
Question / hypotheses
Which partition or latent block structure best explains the supplied graph relationships? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.
Architecture / computational structure
A graph flow model, module codebooks, and map-equation optimization.
Assumptions
Flow communities can differ from modularity communities because they answer different questions. Isolates, directed sinks, and sampling biases affect estimated flow.
Formula / computational definition
The map equation is , where is a partition, total module-exit probability, the distribution of exits, and a module's node/exit codebook with usage rate . Entropy uses a consistent logarithm base.
Parameters and notation
Learned or fitted quantities: Module partition and coding probabilities derived from flow. User-set hyperparameters/design choices: Specify edge direction and weights, flow model, teleportation where needed, and optimization trials. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.
Fitting, fine-tuning, and adaptation
Neural fine-tuning is not applicable. Refit after material edge or weight changes and compare several initializations. Warm-starting a partition can help computation but may preserve an obsolete solution; use the same graph construction when comparing versions.
How to use and calibrate
Compare code lengths under the same flow assumptions, partition stability over trials, and relevance of the implied movement process. Inspect whether edges really represent traversable relationships.
Example application
Group transport nodes according to persistent movement flows. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.
Interpretation / pitfalls
Watch out
The reported result is conditional on the representation and objective. A stable partition can reflect nuisance structure such as batch, collection site, or missingness. Confirm the interpretation in original variables and an independent sample.
Python and R code examples
R provides igraph::cluster_infomap. Either language can evaluate a supplied map equation with basic entropy calculations; complete fitting requires the optimizer. Do not replace transition flows with arbitrary normalized similarities without stating the modeling change.
Component: Map equation from consistent supplied coding rates. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Map equation from consistent supplied coding rates. · needs numpy
import numpy as np
H=lambda p: -sum(v*np.log2(v) for v in p if v>0)
exit_total=.2; exit_codes=[.5,.5]
# Module usage .6 each: node mass .5 plus exit mass .1.
within=[1/6,5/12,5/12]
result=exit_total*H(exit_codes)+2*.6*H(within)
print(result)
Component demo, not a trained model — Map equation from consistent supplied coding rates.
H=function(p) -sum(p[p>0]*log2(p[p>0])); exit_total=.2
within=c(1/6,5/12,5/12)
result=exit_total*H(c(.5,.5))+2*.6*H(within)
print(result)
Sources
- Source 1r.igraph.org
From the CodeSplash reference, entry UCL032.