code: def _compute_rc(G):
      """Returns the rich-club coefficient for each degree in the graph
      `G`.
  
      `G` is an undirected graph without multiedges.
  
      Returns a dictionary mapping degree to rich-club coefficient for
      that degree.
  
      """
      deghist = nx.degree_histogram(G)
      total = sum(deghist)
      # Compute the number of nodes with degree greater than `k`, for each
      # degree `k` (omitting the last entry, which is zero).
      nks = (total - cs for cs in accumulate(deghist) if total - cs > 1)
      # Create a sorted list of pairs of edge endpoint degrees.
      #
      # The list is sorted in reverse order so that we can pop from the
      # right side of the list later, instead of popping from the left
      # side of the list, which would have a linear time cost.
      edge_degrees = sorted(
          (sorted(map(G.degree, e)) for e in G.edges()), reverse=True
      )
      ek = G.number_of_edges()
      k1, k2 = edge_degrees.pop()
      rc = {}
      for d, nk in enumerate(nks):
          while k1 <= d:
              if len(edge_degrees) == 0:
                  ek = 0
                  break
              k1, k2 = edge_degrees.pop()
              ek -= 1
          rc[d] = 2 * ek / (nk * (nk - 1))
      return rc
  
imports: from itertools import accumulate
  import networkx
  from networkx.utils import not_implemented_for
label_desc: Use image node_id 2 for calling a global function with example usage: _compute_rc(G) and returns: rc