Skip to content

Clustering, density estimation, and anomaly detection · Graph and community clustering · UCL028 · Algorithm

Markov clustering (MCL)

Find graph regions that retain random-walk flow by alternating diffusion and nonlinear concentration. Widely applicable to weighted similarity networks where within-group walks are more persistent than between-group…

Runs in CodeSplash (Experimental) Component demo, not a trained model CodeSplash's run and the reference's record

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.

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

Find graph regions that retain random-walk flow by alternating diffusion and nonlinear concentration. Widely applicable to weighted similarity networks where within-group walks are more persistent than between-group walks.

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

Alternating stochastic-matrix expansion and elementwise inflation, with sparse pruning if used.

Assumptions

Directed or weighted inputs require consistent conventions. Pruning improves scalability but can alter weak connectivity. MCL is a graph-flow algorithm, not a mixture likelihood model.

Formula / computational definition

Normalize adjacency with self-loops into a column-stochastic matrix PP. Expansion computes P←PeP\leftarrow P^e, with matrix multiplication; inflation computes Pij←Pijr/∑lPljrP_{ij}\leftarrow P_{ij}^r/\sum_lP_{lj}^r elementwise, where ee is expansion and r>1r>1 inflation. Iteration produces attractor structure from which clusters are extracted.

Parameters and notation

Learned or fitted quantities: An attractor matrix and its extracted graph partition. User-set hyperparameters/design choices: Inflation chiefly controls granularity; expansion, loop weights, pruning, and convergence tolerance also matter. 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 granularity and stability across inflation values, inspect disconnected components, and verify whether communities correspond to useful functional groups. Runtime depends strongly on intermediate matrix sparsity.

Example application

Find functional groups in a protein-similarity graph. 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

The author's mcl executable can be called from either language. R's MCL package documents a native implementation. Small educational examples can implement expansion and inflation directly in NumPy and R matrix operations.

Component: One MCL expansion–inflation cycle. 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.

Python

Component demo, not a trained model — One MCL expansion–inflation cycle. · needs numpy

import numpy as np
P=np.array([[.8,.2],[.2,.8]])
P=P@P; P=P**2; result=P/P.sum(0,keepdims=True)
print(result)
R

Component demo, not a trained model — One MCL expansion–inflation cycle.

P=rbind(c(.8,.2),c(.2,.8)); P=P%*%P; P=P^2
result=sweep(P,2,colSums(P),'/')
print(result)

Sources

From the CodeSplash reference, entry UCL028.