code: def all_pairs_node_connectivity(G, nbunch=None, cutoff=None):
      """Compute node connectivity between all pairs of nodes.
  
      Pairwise or local node connectivity between two distinct and nonadjacent
      nodes is the minimum number of nodes that must be removed (minimum
      separating cutset) to disconnect them. By Menger's theorem, this is equal
      to the number of node independent paths (paths that share no nodes other
      than source and target). Which is what we compute in this function.
  
      This algorithm is a fast approximation that gives an strict lower
      bound on the actual number of node independent paths between two nodes [1]_.
      It works for both directed and undirected graphs.
  
  
      Parameters
      ----------
      G : NetworkX graph
  
      nbunch: container
          Container of nodes. If provided node connectivity will be computed
          only over pairs of nodes in nbunch.
  
      cutoff : integer
          Maximum node connectivity to consider. If None, the minimum degree
          of source or target is used as a cutoff in each pair of nodes.
          Default value None.
  
      Returns
      -------
      K : dictionary
          Dictionary, keyed by source and target, of pairwise node connectivity
  
      Examples
      --------
      A 3 node cycle with one extra node attached has connectivity 2 between all
      nodes in the cycle and connectivity 1 between the extra node and the rest:
  
      >>> G = nx.cycle_graph(3)
      >>> G.add_edge(2, 3)
      >>> import pprint  # for nice dictionary formatting
      >>> pprint.pprint(nx.all_pairs_node_connectivity(G))
      {0: {1: 2, 2: 2, 3: 1},
       1: {0: 2, 2: 2, 3: 1},
       2: {0: 2, 1: 2, 3: 1},
       3: {0: 1, 1: 1, 2: 1}}
  
      See Also
      --------
      local_node_connectivity
      node_connectivity
  
      References
      ----------
      .. [1] White, Douglas R., and Mark Newman. 2001 A Fast Algorithm for
          Node-Independent Paths. Santa Fe Institute Working Paper #01-07-035
          http://eclectic.ss.uci.edu/~drwhite/working.pdf
      """
      if nbunch is None:
          nbunch = G
      else:
          nbunch = set(nbunch)
  
      directed = G.is_directed()
      if directed:
          iter_func = itertools.permutations
      else:
          iter_func = itertools.combinations
  
      all_pairs = {n: {} for n in nbunch}
  
      for u, v in iter_func(nbunch, 2):
          k = local_node_connectivity(G, u, v, cutoff=cutoff)
          all_pairs[u][v] = k
          if not directed:
              all_pairs[v][u] = k
  
      return all_pairs
  
file_path: networkx/networkx/algorithms/approximation/connectivity.py
imports: import itertools
  from operator import itemgetter
  import networkx
label_desc: Use image node_id 3 for calling a global function with example usage: all_pairs_node_connectivity(G, nbunch, cutoff) and returns: all_pairs