Learn R Programming

igraph (version 1.3.5)

sample_smallworld: The Watts-Strogatz small-world model

Description

Generate a graph according to the Watts-Strogatz network model.

Usage

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

smallworld(...)

Value

A graph object.

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.

Author

Gabor Csardi csardi.gabor@gmail.com

Details

First a lattice is created with the given dim, size and nei arguments. Then the edges of the lattice are rewired uniformly randomly with probability p.

Note that this function might create graphs with loops and/or multiple edges. You can use simplify to get rid of these.

References

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

See Also

make_lattice, rewire

Examples

Run this code

g <- sample_smallworld(1, 100, 5, 0.05)
mean_distance(g)
transitivity(g, type="average")

Run the code above in your browser using DataLab