code: def average_clustering(G, nodes=None, mode="dot"):
      r"""Compute the average bipartite clustering coefficient.
  
      A clustering coefficient for the whole graph is the average,
  
      .. math::
  
         C = \frac{1}{n}\sum_{v \in G} c_v,
  
      where `n` is the number of nodes in `G`.
  
      Similar measures for the two bipartite sets can be defined [1]_
  
      .. math::
  
         C_X = \frac{1}{|X|}\sum_{v \in X} c_v,
  
      where `X` is a bipartite set of `G`.
  
      Parameters
      ----------
      G : graph
          a bipartite graph
  
      nodes : list or iterable, optional
          A container of nodes to use in computing the average.
          The nodes should be either the entire graph (the default) or one of the
          bipartite sets.
  
      mode : string
          The pairwise bipartite clustering method.
          It must be "dot", "max", or "min"
  
      Returns
      -------
      clustering : float
         The average bipartite clustering for the given set of nodes or the
         entire graph if no nodes are specified.
  
      Examples
      --------
      >>> from networkx.algorithms import bipartite
      >>> G = nx.star_graph(3)  # star graphs are bipartite
      >>> bipartite.average_clustering(G)
      0.75
      >>> X, Y = bipartite.sets(G)
      >>> bipartite.average_clustering(G, X)
      0.0
      >>> bipartite.average_clustering(G, Y)
      1.0
  
      See Also
      --------
      clustering
  
      Notes
      -----
      The container of nodes passed to this function must contain all of the nodes
      in one of the bipartite sets ("top" or "bottom") in order to compute
      the correct average bipartite clustering coefficients.
      See :mod:`bipartite documentation <networkx.algorithms.bipartite>`
      for further details on how bipartite graphs are handled in NetworkX.
  
  
      References
      ----------
      .. [1] Latapy, Matthieu, Clémence Magnien, and Nathalie Del Vecchio (2008).
          Basic notions for the analysis of large two-mode networks.
          Social Networks 30(1), 31--48.
      """
      if nodes is None:
          nodes = G
      ccs = latapy_clustering(G, nodes=nodes, mode=mode)
      return sum(ccs[v] for v in nodes) / len(nodes)
  
file_path: networkx/networkx/algorithms/bipartite/cluster.py
imports: import itertools
  import networkx
label_desc: Use image node_id 5 for calling a global function with example usage: average_clustering(G, nodes, mode) and returns: unknown