fast_gnp_random_graph#
- fast_gnp_random_graph(n, p, seed=None, directed=False)[source]#
Returns a
random graph, also known as an Erdős-Rényi graph or a binomial graph.- Parameters:
- nint
The number of nodes.
- pfloat
Probability for edge creation.
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
- directedbool, optional (default=False)
If True, this function returns a directed graph.
See also
Notes
The
graph algorithm chooses each of the (undirected) or (directed) possible edges with probability .This algorithm [1] runs in
time, wherem
is the expected number of edges, which equals . This should be faster thangnp_random_graph()
when is small and the expected number of edges is small (that is, the graph is sparse).References
[1]Vladimir Batagelj and Ulrik Brandes, “Efficient generation of large random networks”, Phys. Rev. E, 71, 036113, 2005.