random_graph¶
- random_graph(n, m, p, seed=None, directed=False)[source]¶
Returns a bipartite random graph.
This is a bipartite version of the binomial (Erdős-Rényi) graph. The graph is composed of two partitions. Set A has nodes 0 to (n - 1) and set B has nodes n to (n + m - 1).
- Parameters
- nint
The number of nodes in the first bipartite set.
- mint
The number of nodes in the second bipartite set.
- 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 return a directed graph
See also
gnp_random_graph
,configuration_model
Notes
The bipartite random graph algorithm chooses each of the n*m (undirected) or 2*nm (directed) possible edges with probability p.
This algorithm is \(O(n+m)\) where \(m\) is the expected number of edges.
The nodes are assigned the attribute ‘bipartite’ with the value 0 or 1 to indicate which bipartite set the node belongs to.
This function is not imported in the main namespace. To use it use nx.bipartite.random_graph
References
- 1
Vladimir Batagelj and Ulrik Brandes, “Efficient generation of large random networks”, Phys. Rev. E, 71, 036113, 2005.