Network permutations

As opposed to re-generating networks from a template of probabilities, network permutations shuffles interactions within a network. This is done by enforcing different constraints on degree distribution: either only the fill is maintained, or only the in or out degree, or both.

# EcologicalNetwork.swapsFunction.

Generates permutations of a network

swaps(N::DeterministicNetwork, r::Int64; constraint::Symbol=:degree, swapsize::Int64=3, n::Int64=3000)

By default, this method will look for random (x, x) sub-matrices, where x is given by the swapsize keyword, and shuffle them. There are four possible constraints:

value meaning proba equivalent
:degree both in and out degree null2
:generality only out degree null3out
:vulnerability only in degree null3in
:fill only number of links null1


  1. N, a DeterministicNetwork
  2. r, the number of randomized networks to generate


  • constraint: can be :degree, :generality, :vulnerability, or :fill
  • swapsize: the size of the square sub-matrix to swap (defaults to 3)
  • n: the number of sub-matrices to swap (defaults to 3000)


It is also possible to produce a single permutation of a network if needed.

# EcologicalNetwork.swapFunction.

Swaps a unipartite network while enforcing a constraint on degree distribution.


Generate a single permutation of a network

swap(N::BipartiteNetwork; constraint::Symbol=:degree, swapsize::Int64=3, n::Int64=3000)

Swaps a bipartite network while enforcing a constraint on degree distribution. See the documentation for swaps for the complete explanation of arguments.