aryagraph.generators.random.erdos_renyi#

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

G(n, p): every possible edge (arc, if directed) is present independently with probability p.

Uses geometric skipping, so the cost is O(n + m) rather than O(n²) for sparse graphs. No self-loops. The expected edge count is p·n(n-1)/2 (p·n(n-1) directed).

>>> g = erdos_renyi(1000, 0.005, seed=1)