code: def inter_community_non_edges(G, partition):
      """Returns the number of inter-community non-edges according to the
      given partition of the nodes of `G`.
  
      Parameters
      ----------
      G : NetworkX graph.
  
      partition : iterable of sets of nodes
          This must be a partition of the nodes of `G`.
  
      A *non-edge* is a pair of nodes (undirected if `G` is undirected)
      that are not adjacent in `G`. The *inter-community non-edges* are
      those non-edges on a pair of nodes in different blocks of the
      partition.
  
      Implementation note: this function creates two intermediate graphs,
      which may require up to twice the amount of memory as required to
      store `G`.
  
      """
      # Alternate implementation that does not require constructing two
      # new graph objects (but does require constructing an affiliation
      # dictionary):
      #
      #     aff = dict(chain.from_iterable(((v, block) for v in block)
      #                                    for block in partition))
      #     return sum(1 for u, v in nx.non_edges(G) if aff[u] != aff[v])
      #
      return inter_community_edges(nx.complement(G), partition)
  
file_path: networkx/networkx/algorithms/community/quality.py
imports: from itertools import combinations
  import networkx
  from networkx import NetworkXError
  from networkx.algorithms.community.community_utils import is_partition
  from networkx.utils.decorators import argmap
label_desc: Use image node_id 4 for calling a global function with example usage: inter_community_non_edges(G, partition) and returns: inter_community_edges