Skip to main content
`Ctrl`+`K`

# random_reference

random_reference(G, niter=1, connectivity=True, seed=None)

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

  Parameters:
    G graph

      An undirected graph with 4 or more nodes.

    niter integer (optional, default=1)

      An edge is rewired approximately `niter` times.

    connectivity boolean (optional, default=True)

      When True, ensure connectivity for the randomized graph.

    seed integer, random_state, or None (default)

      Indicator of random number generation state. See Randomness.

  Returns:
    G graph

      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.