- connected_watts_strogatz_graph(n, k, p, tries=100, seed=None)[source]#
Returns a connected Watts–Strogatz small-world graph.
Attempts to generate a connected graph by repeated generation of Watts–Strogatz small-world graphs. An exception is raised if the maximum number of tries is exceeded.
The number of nodes
Each node is joined with its
knearest neighbors in a ring topology.
The probability of rewiring each edge
Number of attempts to generate a connected graph.
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
First create a ring over \(n\) nodes . Then each node in the ring is joined to its \(k\) nearest neighbors (or \(k - 1\) neighbors if \(k\) is odd). Then shortcuts are created by replacing some edges as follows: for each edge \((u, v)\) in the underlying “\(n\)-ring with \(k\) nearest neighbors” with probability \(p\) replace it with a new edge \((u, w)\) with uniformly random choice of existing node \(w\). The entire process is repeated until a connected graph results.
Duncan J. Watts and Steven H. Strogatz, Collective dynamics of small-world networks, Nature, 393, pp. 440–442, 1998.