Skip to contents

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.

Usage

sample_smallworld(dim, size, nei, p, loops = FALSE, multiple = FALSE)

smallworld(...)

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().

Value

A graph object.

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.

Author

Gabor Csardi csardi.gabor@gmail.com

Examples


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