random_reference#

random_reference(G, niter=1, connectivity=True, seed=None)[source]#

Compute a random graph by swapping edges of a given graph.

Parameters:
Ggraph

An undirected graph with 4 or more nodes.

niterinteger (optional, default=1)

An edge is rewired approximately niter times.

connectivityboolean (optional, default=True)

When True, ensure connectivity for the randomized graph.

seedinteger, random_state, or None (default)

Indicator of random number generation state. See Randomness.

Returns:
Ggraph

The randomized graph.

Raises:
NetworkXError

If there are fewer than 4 nodes or 2 edges in G

Notes

The implementation is adapted from the algorithm by Maslov and Sneppen (2002) [1].

References

[1]

Maslov, Sergei, and Kim Sneppen. ‚ÄúSpecificity and stability in topology of protein networks.‚ÄĚ Science 296.5569 (2002): 910-913.