def is_dominating_set(G, nbunch):
 testset = set((n for n in nbunch if (n in G)))
 nbrs = set(chain.from_iterable((G[n] for n in testset)))
 return (len(((set(G) - testset) - nbrs)) == 0)

def is_dominating_set ( G , nbunch ) : testset = set ( ( n for n in nbunch if ( n in G ) ) ) nbrs = set ( chain . from_iterable ( ( G [ n ] for n in testset ) ) ) return ( len ( ( ( set ( G ) - testset ) - nbrs ) ) == 0 )
checks if nbunch is a dominating set for g .