2.9. igraph_rewire — Randomly rewires a graph while preserving the degree distribution.

int igraph_rewire(igraph_t *graph, igraph_integer_t n, igraph_rewiring_t mode);

This function generates a new graph based on the original one by randomly rewiring edges while preserving the original graph's degree distribution. Please note that the rewiring is done "in place", so no new graph will be allocated. If you would like to keep the original graph intact, use igraph_copy() before.

Arguments: 

graph:

The graph object to be rewired.

n:

Number of rewiring trials to perform.

mode:

The rewiring algorithm to be used. It can be one of the following: IGRAPH_REWIRING_SIMPLE: simple rewiring algorithm which chooses two arbitrary edges in each step (namely (a,b) and (c,d)) and substitutes them with (a,d) and (c,b) if they don't exist. Time complexity: TODO.

Returns: 

Error code:

IGRAPH_EINVMODE

Invalid rewiring mode.

IGRAPH_EINVAL

Graph unsuitable for rewiring (e.g. it has less than 4 nodes in case of IGRAPH_REWIRING_SIMPLE)

IGRAPH_ENOMEM

Not enough memory for temporary data.

Time complexity: TODO.