This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
watts_strogatz_graph(n, k, p, seed=None)¶
Return a Watts–Strogatz small-world graph.
First create a ring over
nnodes. Then each node in the ring is joined to its
knearest neighbors (or
k - 1neighbors if
kis odd). Then shortcuts are created by replacing some edges as follows: for each edge
(u, v)in the underlying “
knearest neighbors” with probability
preplace it with a new edge
(u, w)with uniformly random choice of existing node
 Duncan J. Watts and Steven H. Strogatz, Collective dynamics of small-world networks, Nature, 393, pp. 440–442, 1998.