- newman_watts_strogatz_graph(n, k, p, seed=None)¶
Returns a Newman–Watts–Strogatz small-world graph.
The number of nodes.
Each node is joined with its
knearest neighbors in a ring topology.
The probability of adding a new edge for each edge.
- 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 connected with its \(k\) nearest neighbors (or \(k - 1\) neighbors if \(k\) is odd). Then shortcuts are created by adding new edges as follows: for each edge \((u, v)\) in the underlying “\(n\)-ring with \(k\) nearest neighbors” with probability \(p\) add a new edge \((u, w)\) with randomly-chosen existing node \(w\). In contrast with
watts_strogatz_graph(), no edges are removed.