NetworkX

Previous topic

networkx.tutte_graph

Next topic

networkx.gnp_random_graph

networkx.fast_gnp_random_graph

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

Return a random graph G_{n,p}.

The G_{n,p} graph choses each of the possible [n(n-1)]/2 edges with probability p.

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 algorithm is O(n+m) where m is the expected number of edges m=p*n*(n-1)/2.

It should be faster than gnp_random_graph when p is small, and the expected number of edges is small, (sparse graph).

References

[R11]Batagelj and Brandes, “Efficient generation of large random networks”, Phys. Rev. E, 71, 036113, 2005.