code: def local_node_connectivity(G, source, target, cutoff=None):
      """Compute node connectivity between source and target.
  
      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
  
      source : node
          Starting node for node connectivity
  
      target : node
          Ending node for node connectivity
  
      cutoff : integer
          Maximum node connectivity to consider. If None, the minimum degree
          of source or target is used as a cutoff. Default value None.
  
      Returns
      -------
      k: integer
         pairwise node connectivity
  
      Examples
      --------
      >>> # Platonic octahedral graph has node connectivity 4
      >>> # for each non adjacent node pair
      >>> from networkx.algorithms import approximation as approx
      >>> G = nx.octahedral_graph()
      >>> approx.local_node_connectivity(G, 0, 5)
      4
  
      Notes
      -----
      This algorithm [1]_ finds node independents paths between two nodes by
      computing their shortest path using BFS, marking the nodes of the path
      found as 'used' and then searching other shortest paths excluding the
      nodes marked as used until no more paths exist. It is not exact because
      a shortest path could use nodes that, if the path were longer, may belong
      to two different node independent paths. Thus it only guarantees an
      strict lower bound on node connectivity.
  
      Note that the authors propose a further refinement, losing accuracy and
      gaining speed, which is not implemented yet.
  
      See also
      --------
      all_pairs_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 target == source:
          raise nx.NetworkXError(
              "source and target have to be different nodes."
          )
  
      # Maximum possible node independent paths
      if G.is_directed():
          possible = min(G.out_degree(source), G.in_degree(target))
      else:
          possible = min(G.degree(source), G.degree(target))
  
      K = 0
      if not possible:
          return K
  
      if cutoff is None:
          cutoff = float("inf")
  
      exclude = set()
      for i in range(min(possible, cutoff)):
          try:
              path = _bidirectional_shortest_path(
                  G, source, target, exclude
              )
              exclude.update(set(path))
              K += 1
          except nx.NetworkXNoPath:
              break
  
      return K
  
file_path: networkx/networkx/algorithms/approximation/connectivity.py
imports: import itertools
  from operator import itemgetter
  import networkx
label_desc: Use image node_id 1 for calling a global function with example usage: local_node_connectivity(G, source, target, cutoff) and returns: K, K