def _reciprocity_iter(G, nodes):
 n = G.nbunch_iter(nodes)
 for node in n:
  pred = set(G.predecessors(node))
  succ = set(G.successors(node))
  overlap = (pred & succ)
  n_total = (len(pred) + len(succ))
  if (n_total == 0):
   (yield (node, None))
  else:
   reciprocity = ((2.0 * float(len(overlap))) / float(n_total))
   (yield (node, reciprocity))

def _reciprocity_iter ( G , nodes ) : n = G . nbunch_iter ( nodes ) for node in n : pred = set ( G . predecessors ( node ) ) succ = set ( G . successors ( node ) ) overlap = ( pred & succ ) n_total = ( len ( pred ) + len ( succ ) ) if ( n_total == 0 ) : ( yield ( node , None ) ) else : reciprocity = ( ( 2.0 * float ( len ( overlap ) ) ) / float ( n_total ) ) ( yield ( node , reciprocity ) )
return an iterator of .