This function generates networks with the small-world property
based on a variant of the Watts-Strogatz model. The network is obtained
by first creating a periodic undirected lattice, then rewiring both
endpoints of each edge with probability `p`

, while avoiding the
creation of multi-edges.

## Arguments

- dim
Integer constant, the dimension of the starting lattice.

- size
Integer constant, the size of the lattice along each dimension.

- nei
Integer constant, the neighborhood within which the vertices of the lattice will be connected.

- p
Real constant between zero and one, the rewiring probability.

- loops
Logical scalar, whether loops edges are allowed in the generated graph.

- multiple
Logical scalar, whether multiple edges are allowed int the generated graph.

- ...
Passed to

`sample_smallworld()`

.

## Details

Note that this function might create graphs with loops and/or multiple
edges. You can use `simplify()`

to get rid of these.

This process differs from the original model of Watts and Strogatz
(see reference) in that it rewires **both** endpoints of edges. Thus in
the limit of `p=1`

, we obtain a G(n,m) random graph with the
same number of vertices and edges as the original lattice. In comparison,
the original Watts-Strogatz model only rewires a single endpoint of each edge,
thus the network does not become fully random even for `p=1`

.
For appropriate choices of `p`

, both models exhibit the property of
simultaneously having short path lengths and high clustering.

## References

Duncan J Watts and Steven H Strogatz: Collective dynamics of ‘small world’ networks, Nature 393, 440-442, 1998.

## See also

Random graph models (games)
`erdos.renyi.game()`

,
`sample_()`

,
`sample_bipartite()`

,
`sample_chung_lu()`

,
`sample_correlated_gnp()`

,
`sample_correlated_gnp_pair()`

,
`sample_degseq()`

,
`sample_dot_product()`

,
`sample_fitness()`

,
`sample_fitness_pl()`

,
`sample_forestfire()`

,
`sample_gnm()`

,
`sample_gnp()`

,
`sample_grg()`

,
`sample_growing()`

,
`sample_hierarchical_sbm()`

,
`sample_islands()`

,
`sample_k_regular()`

,
`sample_last_cit()`

,
`sample_pa()`

,
`sample_pa_age()`

,
`sample_pref()`

,
`sample_sbm()`

,
`sample_traits_callaway()`

,
`sample_tree()`

## Author

Gabor Csardi csardi.gabor@gmail.com

## Examples

```
g <- sample_smallworld(1, 100, 5, 0.05)
mean_distance(g)
#> [1] 2.647273
transitivity(g, type = "average")
#> [1] 0.480811
```