def average_neighbor_degree(G, source='out', target='out', nodes=None, weight=None):
 source_degree = G.degree
 target_degree = G.degree
 if G.is_directed():
  direction = {'out': G.out_degree, 'in': G.in_degree}
  source_degree = direction[source]
  target_degree = direction[target]
 return _average_nbr_deg(G, source_degree, target_degree, nodes=nodes, weight=weight)

def average_neighbor_degree ( G , source = 'out' , target = 'out' , nodes = None , weight = None ) : source_degree = G . degree target_degree = G . degree if G . is_directed ( ) : direction = { 'out' : G . out_degree , 'in' : G . in_degree } source_degree = direction [ source ] target_degree = direction [ target ] return _average_nbr_deg ( G , source_degree , target_degree , nodes = nodes , weight = weight )
returns the average degree of the neighborhood of each node .