Skip to main content
`Ctrl`+`K`

# dense_gnm_random_graph

dense_gnm_random_graph(n, m, seed=None, *, create_using=None)

  Returns a \(G_{n,m}\) random graph.

  In the \(G_{n,m}\) model, a graph is chosen uniformly at random from 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 int

      The number of nodes.

    m int

      The number of edges.

    seed integer, random_state, or None (default)

      Indicator of random number generation state. See Randomness.

    create_using Graph constructor, optional (default=nx.Graph)

      Graph type to create. If graph instance, then cleared before populated. Multigraph and directed types are not supported and raise a `NetworkXError`.

  See also

  `gnm_random_graph`

  Notes

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

  References

  [1]

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