This function can be used together with `rewire()`

to
randomly rewire the edges while preserving the original graph's degree
distribution.

## Arguments

- loops
Whether to allow destroying and creating loop edges.

- niter
Number of rewiring trials to perform.

## Details

The rewiring algorithm chooses two arbitrary edges in each step ((a,b) and (c,d)) and substitutes them with (a,d) and (c,b), if they not already exists in the graph. The algorithm does not create multiple edges.

## Author

Tamas Nepusz ntamas@gmail.com and Gabor Csardi csardi.gabor@gmail.com

## Examples

```
g <- make_ring(10)
g %>%
rewire(keeping_degseq(niter = 20)) %>%
degree()
#> [1] 2 2 2 2 2 2 2 2 2 2
print_all(rewire(g, with = keeping_degseq(niter = vcount(g) * 10)))
#> IGRAPH 0c244ff U--- 10 10 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l)
#> + graph attributes:
#> | + name:
#> | [1] "Ring graph"
#> | + mutual:
#> | [1] FALSE
#> | + circular:
#> | [1] TRUE
#> + edges from 0c244ff:
#> [1] 4-- 7 4-- 5 3-- 5 6-- 9 2-- 9 1-- 8 3-- 6 8--10 1-- 2 7--10
```