code: def closeness_centrality(G, nodes, normalized=True):
      r"""Compute the closeness centrality for nodes in a bipartite network.
  
      The closeness of a node is the distance to all other nodes in the
      graph or in the case that the graph is not connected to all other nodes
      in the connected component containing that node.
  
      Parameters
      ----------
      G : graph
          A bipartite network
  
      nodes : list or container
          Container with all nodes in one bipartite node set.
  
      normalized : bool, optional
        If True (default) normalize by connected component size.
  
      Returns
      -------
      closeness : dictionary
          Dictionary keyed by node with bipartite closeness centrality
          as the value.
  
      Examples
      --------
      >>> G = nx.wheel_graph(5)
      >>> top_nodes = {0, 1, 2}
      >>> nx.bipartite.closeness_centrality(G, nodes=top_nodes)
      {0: 1.5, 1: 1.2, 2: 1.2, 3: 1.0, 4: 1.0}
  
      See Also
      --------
      betweenness_centrality
      degree_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.
  
  
      Closeness centrality is normalized by the minimum distance possible.
      In the bipartite case the minimum distance for a node in one bipartite
      node set is 1 from all nodes in the other node set and 2 from all
      other nodes in its own set [1]_. Thus the closeness centrality
      for node `v`  in the two bipartite sets `U` with
      `n` nodes and `V` with `m` nodes is
  
      .. math::
  
          c_{v} = \frac{m + 2(n - 1)}{d}, \mbox{for} v \in U,
  
          c_{v} = \frac{n + 2(m - 1)}{d}, \mbox{for} v \in V,
  
      where `d` is the sum of the distances from `v` to all
      other nodes.
  
      Higher values of closeness  indicate higher centrality.
  
      As in the unipartite case, setting normalized=True causes the
      values to normalized further to n-1 / size(G)-1 where n is the
      number of nodes in the connected part of graph containing the
      node.  If the graph is not completely connected, this algorithm
      computes the closeness centrality for each connected part
      separately.
  
      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
      """
      closeness = {}
      path_length = nx.single_source_shortest_path_length
      top = set(nodes)
      bottom = set(G) - top
      n = len(top)
      m = len(bottom)
      for node in top:
          sp = dict(path_length(G, node))
          totsp = sum(sp.values())
          if totsp > 0.0 and len(G) > 1:
              closeness[node] = (m + 2 * (n - 1)) / totsp
              if normalized:
                  s = (len(sp) - 1) / (len(G) - 1)
                  closeness[node] *= s
          else:
              closeness[node] = 0.0
      for node in bottom:
          sp = dict(path_length(G, node))
          totsp = sum(sp.values())
          if totsp > 0.0 and len(G) > 1:
              closeness[node] = (n + 2 * (m - 1)) / totsp
              if normalized:
                  s = (len(sp) - 1) / (len(G) - 1)
                  closeness[node] *= s
          else:
              closeness[node] = 0.0
      return closeness
  
imports: import networkx
label_desc: Use image node_id 3 for calling a global function with example usage: closeness_centrality(G, nodes, normalized) and returns: closeness