def average_node_connectivity(G, flow_func=None):
 if G.is_directed():
  iter_func = itertools.permutations
 else:
  iter_func = itertools.combinations
 H = build_auxiliary_node_connectivity(G)
 R = build_residual_network(H, 'capacity')
 kwargs = dict(flow_func=flow_func, auxiliary=H, residual=R)
 (num, den) = (0, 0)
 for (u, v) in iter_func(G, 2):
  num += local_node_connectivity(G, u, v, **kwargs)
  den += 1
 if (den == 0):
  return 0
 return (num / den)

def average_node_connectivity ( G , flow_func = None ) : if G . is_directed ( ) : iter_func = itertools . permutations else : iter_func = itertools . combinations H = build_auxiliary_node_connectivity ( G ) R = build_residual_network ( H , 'capacity' ) kwargs = dict ( flow_func = flow_func , auxiliary = H , residual = R ) ( num , den ) = ( 0 , 0 ) for ( u , v ) in iter_func ( G , 2 ) : num += local_node_connectivity ( G , u , v , ** kwargs ) den += 1 if ( den == 0 ) : return 0 return ( num / den )
returns the average connectivity of a graph g .