code: def dense_gnm_random_graph(n, m, seed=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 :func:`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 :ref:`Randomness<randomness>`.
  
      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.
      """
      mmax = n * (n - 1) // 2
      if m >= mmax:
          G = complete_graph(n)
      else:
          G = empty_graph(n)
  
      if n == 1 or m >= mmax:
          return G
  
      u = 0
      v = 1
      t = 0
      k = 0
      while True:
          if seed.randrange(mmax - t) < m - k:
              G.add_edge(u, v)
              k += 1
              if k == m:
                  return G
          t += 1
          v += 1
          if v == n:  # go to next row of adjacency matrix
              u += 1
              v = u + 1
  
imports: import itertools
  import math
  from collections import defaultdict
  import networkx
  from networkx.utils import py_random_state
  from .classic import complete_graph, empty_graph, path_graph, star_graph
  from .degree_seq import degree_sequence_tree
label_desc: Use image node_id 3 for calling a global function with example usage: dense_gnm_random_graph(n, m, seed) and returns: G, G