File Exchange

image thumbnail


version 1.2 (185 KB) by

A Matlab package to randomize and sample networks by a max-entropy approach for several null models



View License

This software package samples and/or randomizes networks according to an unbiased maximum-entropy method. It addresses the solution of the maximum-entropy problem for seven null-models according to different constraints and input-data. The maximum-entropy methodology belongs to the group of analytical approaches for randomizing networks.
Sampling random graphs with given properties is a key step in the analysis of networks, as random ensembles represent basic null models required to identify patterns such as communities and motifs. A key requirement is that the sampling process is unbiased and efficient. The main approaches are microcanonical, i.e. they sample graphs that exactly match the enforced constraints. Unfortunately, when applied to strongly heterogeneous networks (including most real-world graphs), the majority of these approaches become biased and/or time-consuming. Moreover, the algorithms defined in the simplest cases (such as binary graphs with given degrees) are not easily generalizable to more complicated ensembles. Here we propose an algorithm based on the ‘maximize-and-sample’ (‘Max & Sam’) method to correctly sample ensembles of networks where the constraints are ‘soft’ i.e. they are realized as ensemble averages. Being based on exact maximum- entropy distributions, our approach is unbiased by construction, even for strongly heterogeneous networks. It is also more computationally efficient than most microcanonical alternatives. Finally, it works for both binary and weighted networks with a variety of constraints, including combined degree-strengths sequences and full reciprocity structure, for which no alternative method exists. Our method can also be turned into a microcanonical one, via a restriction to the relevant subset.
The package has been introduced in the paper “Unbiased sampling of network ensembles” (Squartini, Mastrandrea and Garlaschelli, 2014)
For the theoretical methodology concerning it see:

[1] Garlaschelli, D. and Loffredo, M. I. (2008). Maximum likelihood: Extracting unbiased information from complex networks. Physical Review E, 78(1):015101.

[2] Garlaschelli, D. and Loffredo, M. I. (2009). Generalized bose-fermi statistics and structural correlations in weighted networks. Physical Review Letters, 102(3):038701.

[3] Squartini, T. and Garlaschelli, D. (2011). Analytical maximum-likelihood method to detect patterns in real networks. New Journal of Physics, 13:083001.

All the other references related to the specific null models implemented can be found in the “Read_me” file.

Please, remember to properly cite the paper(s) each time you show any result that builds upon the use of this routine.

Comments and Ratings (0)



The "is_in_class" routine added to the package. Useful for the RWCM sampling.


Description updates

MATLAB Release
MATLAB 7.9 (R2009b)

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video