NetworkX

Previous topic

networkx.gnp_random_graph

Next topic

networkx.gnm_random_graph

Quick search

networkx.dense_gnm_random_graph

dense_gnm_random_graph(n, m, seed=None)

Return the random graph G_{n,m}.

Gives a graph picked randomly out of the set of all graphs with n nodes and m edges. This algorithm should be faster than gnm_random_graph for dense graphs.

Parameters:
  • n: the number of nodes
  • m: the number of edges
  • seed: seed for random number generator (default=None)

Algorithm by Keith M. Briggs Mar 31, 2006. Inspired by Knuth’s Algorithm S (Selection sampling technique), in section 3.4.2 of

The Art of Computer Programming by Donald E. Knuth Volume 2 / Seminumerical algorithms Third Edition, Addison-Wesley, 1997.