Skip to main content
`Ctrl`+`K`

# newman_watts_strogatz_graph

newman_watts_strogatz_graph(n, k, p, seed=None, *, create_using=None)

  Returns a Newman–Watts–Strogatz small-world graph.

  Parameters:
    n int

      The number of nodes.

    k int

      Each node is joined with its `k` nearest neighbors in a ring topology.

    p float

      The probability of adding a new edge for each edge.

    seed integer, random_state, or None (default)

      Indicator of random number generation state. See Randomness.

    create_using Graph constructor, optional (default=nx.Graph)

      Graph type to create. If graph instance, then cleared before populated. Multigraph and directed types are not supported and raise a `NetworkXError`.

  See also

  `watts_strogatz_graph`

  Notes

  First create a ring over \(n\) nodes [1]. 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.

  References

  [1]

  M. E. J. Newman and D. J. Watts, Renormalization group analysis of the small-world network model, Physics Letters A, 263, 341, 1999. https://doi.org/10.1016/S0375-9601(99)00757-4