aryagraph.generators.random.random_regular#
- aryagraph.generators.random.random_regular(d: int, n: int, *, seed: int | Generator | None = None, max_tries: int = 1000) Graph[source]#
Random
d-regular simple graph onnnodes (argument order as in networkx).Pairs degree “stubs” at random and re-pairs only the stubs that would create a loop or duplicate, restarting when that gets stuck (the Steger–Wormald scheme networkx uses). For
d > (n-1)/2the complement of a random(n-1-d)-regular graph is returned, which is much faster and always succeeds. Requires0 <= d < nandn·deven.Raises
ConvergenceErrorif max_tries restarts all fail (practically never).