def node_degree_xy(G, x='out', y='in', weight=None, nodes=None):
 if (nodes is None):
  nodes = set(G)
 else:
  nodes = set(nodes)
 xdeg = G.degree
 ydeg = G.degree
 if G.is_directed():
  direction = {'out': G.out_degree, 'in': G.in_degree}
  xdeg = direction[x]
  ydeg = direction[y]
 for (u, degu) in xdeg(nodes, weight=weight):
  neighbors = (nbr for (_, nbr) in G.edges(u) if (nbr in nodes))
  for (v, degv) in ydeg(neighbors, weight=weight):
   (yield (degu, degv))

def node_degree_xy ( G , x = 'out' , y = 'in' , weight = None , nodes = None ) : if ( nodes is None ) : nodes = set ( G ) else : nodes = set ( nodes ) xdeg = G . degree ydeg = G . degree if G . is_directed ( ) : direction = { 'out' : G . out_degree , 'in' : G . in_degree } xdeg = direction [ x ] ydeg = direction [ y ] for ( u , degu ) in xdeg ( nodes , weight = weight ) : neighbors = ( nbr for ( _ , nbr ) in G . edges ( u ) if ( nbr in nodes ) ) for ( v , degv ) in ydeg ( neighbors , weight = weight ) : ( yield ( degu , degv ) )
generate node degree-degree pairs for edges in g .