NetworkX

Previous topic

networkx.generators.random_graphs.fast_gnp_random_graph

Next topic

networkx.generators.random_graphs.directed_gnp_random_graph

networkx.generators.random_graphs.gnp_random_graph

gnp_random_graph(n, p, create_using=None, seed=None)

Return a random graph G_{n,p}.

Choses each of the possible [n(n-1)]/2 edges with probability p. This is the same as binomial_graph and erdos_renyi_graph.

Sometimes called Erdős-Rényi graph, or binomial graph.

Parameters:

n : int

The number of nodes.

p : float

Probability for edge creation.

create_using : graph, optional (default Graph)

Use specified graph as a container.

seed : int, optional

Seed for random number generator (default=None).

Notes

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

References

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