aryagraph.generators.random.watts_strogatz#

aryagraph.generators.random.watts_strogatz(n: int, k: int, p: float, *, seed: int | Generator | None = None) → Graph[source]#

Watts–Strogatz small world.

Starts from a ring where each node links to its k // 2 nearest neighbors on each side, then rewires the far end of every edge with probability p to a uniformly chosen node, avoiding self-loops and duplicates (networkx’s procedure). The edge count n·(k // 2) is preserved. k == n gives the complete graph; k > n is an error.