def all_pairs_node_connectivity(G, nbunch=None, flow_func=None):
 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}
 H = build_auxiliary_node_connectivity(G)
 mapping = H.graph['mapping']
 R = build_residual_network(H, 'capacity')
 kwargs = dict(flow_func=flow_func, auxiliary=H, residual=R)
 for (u, v) in iter_func(nbunch, 2):
  K = local_node_connectivity(G, u, v, **kwargs)
  all_pairs[u][v] = K
  if (not directed):
   all_pairs[v][u] = K
 return all_pairs

def all_pairs_node_connectivity ( G , nbunch = None , flow_func = None ) : 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 } H = build_auxiliary_node_connectivity ( G ) mapping = H . graph [ 'mapping' ] R = build_residual_network ( H , 'capacity' ) kwargs = dict ( flow_func = flow_func , auxiliary = H , residual = R ) for ( u , v ) in iter_func ( nbunch , 2 ) : K = local_node_connectivity ( G , u , v , ** kwargs ) all_pairs [ u ] [ v ] = K if ( not directed ) : all_pairs [ v ] [ u ] = K return all_pairs
compute node connectivity between all pairs of nodes of g .