NetworkX

Previous topic

gnm_random_graph

Next topic

binomial_graph

erdos_renyi_graph

erdos_renyi_graph(n, p, seed=None, directed=False)

Return a random graph G_{n,p} (Erdős-Rényi graph, binomial graph).

Chooses each of the possible edges with probability p.

This is also called binomial_graph and erdos_renyi_graph.

Parameters :

n : int

The number of nodes.

p : float

Probability for edge creation.

seed : int, optional

Seed for random number generator (default=None).

directed : bool, optional (default=False)

If True return a directed graph

Notes

This is an O(n^2) algorithm. For sparse graphs (small p) see fast_gnp_random_graph for a faster algorithm.

References

[R232]
  1. Erdős and A. Rényi, On Random Graphs, Publ. Math. 6, 290 (1959).
[R233]
    1. Gilbert, Random Graphs, Ann. Math. Stat., 30, 1141 (1959).