def node_expansion(G, S):
 neighborhood = set(chain.from_iterable((G.neighbors(v) for v in S)))
 return (len(neighborhood) / len(S))

def node_expansion ( G , S ) : neighborhood = set ( chain . from_iterable ( ( G . neighbors ( v ) for v in S ) ) ) return ( len ( neighborhood ) / len ( S ) )
returns the node expansion of the set s .