Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
watts_strogatz_graph¶
-
watts_strogatz_graph(n, k, p, seed=None)[source]¶ Return a Watts–Strogatz small-world graph.
Parameters: Notes
First create a ring over
nnodes. Then each node in the ring is joined to itsknearest neighbors (ork - 1neighbors ifkis odd). Then shortcuts are created by replacing some edges as follows: for each edge(u, v)in the underlying “n-ring withknearest neighbors” with probabilitypreplace it with a new edge(u, w)with uniformly random choice of existing nodew.In contrast with
newman_watts_strogatz_graph(), the random rewiring does not increase the number of edges. The rewired graph is not guaranteed to be connected as inconnected_watts_strogatz_graph().References
[1] Duncan J. Watts and Steven H. Strogatz, Collective dynamics of small-world networks, Nature, 393, pp. 440–442, 1998.