Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

gnm_random_graph¶

gnm_random_graph(n, m, seed=None, directed=False)[source]

Returns a random graph.

In the model, a graph is chosen uniformly at random from the set of all graphs with nodes and edges.

This algorithm should be faster than dense_gnm_random_graph() for sparse graphs.

Parameters: n (int) – The number of nodes. m (int) – The number of edges. seed (int, optional) – Seed for random number generator (default=None). directed (bool, optional (default=False)) – If True return a directed graph