def from_dict_of_lists(d, create_using=None):
 G = _prep_create_using(create_using)
 G.add_nodes_from(d)
 if (G.is_multigraph() and (not G.is_directed())):
  seen = {}
  for (node, nbrlist) in d.items():
   for nbr in nbrlist:
    if (nbr not in seen):
     G.add_edge(node, nbr)
   seen[node] = 1
 else:
  G.add_edges_from(((node, nbr) for (node, nbrlist) in d.items() for nbr in nbrlist))
 return G

def from_dict_of_lists ( d , create_using = None ) : G = _prep_create_using ( create_using ) G . add_nodes_from ( d ) if ( G . is_multigraph ( ) and ( not G . is_directed ( ) ) ) : seen = { } for ( node , nbrlist ) in d . items ( ) : for nbr in nbrlist : if ( nbr not in seen ) : G . add_edge ( node , nbr ) seen [ node ] = 1 else : G . add_edges_from ( ( ( node , nbr ) for ( node , nbrlist ) in d . items ( ) for nbr in nbrlist ) ) return G
return a graph from a dictionary of lists .