code: def betweenness_centrality(G, nodes):
      r"""Compute betweenness centrality for nodes in a bipartite network.
  
      Betweenness centrality of a node `v` is the sum of the
      fraction of all-pairs shortest paths that pass through `v`.
  
      Values of betweenness are normalized by the maximum possible
      value which for bipartite graphs is limited by the relative size
      of the two node sets [1]_.
  
      Let `n` be the number of nodes in the node set `U` and
      `m` be the number of nodes in the node set `V`, then
      nodes in `U` are normalized by dividing by
  
      .. math::
  
         \frac{1}{2} [m^2 (s + 1)^2 + m (s + 1)(2t - s - 1) - t (2s - t + 3)] ,
  
      where
  
      .. math::
  
          s = (n - 1) \div m , t = (n - 1) \mod m ,
  
      and nodes in `V` are normalized by dividing by
  
      .. math::
  
          \frac{1}{2} [n^2 (p + 1)^2 + n (p + 1)(2r - p - 1) - r (2p - r + 3)] ,
  
      where,
  
      .. math::
  
          p = (m - 1) \div n , r = (m - 1) \mod n .
  
      Parameters
      ----------
      G : graph
          A bipartite graph
  
      nodes : list or container
          Container with all nodes in one bipartite node set.
  
      Returns
      -------
      betweenness : dictionary
          Dictionary keyed by node with bipartite betweenness centrality
          as the value.
  
      Examples
      --------
      >>> G = nx.cycle_graph(4)
      >>> top_nodes = {1, 2}
      >>> nx.bipartite.betweenness_centrality(G, nodes=top_nodes)
      {0: 0.25, 1: 0.25, 2: 0.25, 3: 0.25}
  
      See Also
      --------
      degree_centrality
      closeness_centrality
      :func:`~networkx.algorithms.bipartite.basic.sets`
      :func:`~networkx.algorithms.bipartite.basic.is_bipartite`
  
      Notes
      -----
      The nodes input parameter must contain all nodes in one bipartite node set,
      but the dictionary returned contains all nodes from both node sets.
      See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
      for further details on how bipartite graphs are handled in NetworkX.
  
  
      References
      ----------
      .. [1] Borgatti, S.P. and Halgin, D. In press. "Analyzing Affiliation
          Networks". In Carrington, P. and Scott, J. (eds) The Sage Handbook
          of Social Network Analysis. Sage Publications.
          https://dx.doi.org/10.4135/9781446294413.n28
      """
      top = set(nodes)
      bottom = set(G) - top
      n = len(top)
      m = len(bottom)
      s, t = divmod(n - 1, m)
      bet_max_top = (
          ((m**2) * ((s + 1) ** 2))
          + (m * (s + 1) * (2 * t - s - 1))
          - (t * ((2 * s) - t + 3))
      ) / 2.0
      p, r = divmod(m - 1, n)
      bet_max_bot = (
          ((n**2) * ((p + 1) ** 2))
          + (n * (p + 1) * (2 * r - p - 1))
          - (r * ((2 * p) - r + 3))
      ) / 2.0
      betweenness = nx.betweenness_centrality(
          G, normalized=False, weight=None
      )
      for node in top:
          betweenness[node] /= bet_max_top
      for node in bottom:
          betweenness[node] /= bet_max_bot
      return betweenness
  
imports: import networkx
label_desc: Use image node_id 2 for calling a global function with example usage: betweenness_centrality(G, nodes) and returns: betweenness