def add_star(G, nodes, **attr):
 nlist = iter(nodes)
 v = next(nlist)
 edges = ((v, n) for n in nlist)
 G.add_edges_from(edges, **attr)

def add_star ( G , nodes , ** attr ) : nlist = iter ( nodes ) v = next ( nlist ) edges = ( ( v , n ) for n in nlist ) G . add_edges_from ( edges , ** attr )
add a star to graph g .