def generate_adjlist(G, delimiter=' '):
 directed = G.is_directed()
 seen = set()
 for (s, nbrs) in G.adjacency():
  line = (make_str(s) + delimiter)
  for (t, data) in nbrs.items():
   if ((not directed) and (t in seen)):
    continue
   if G.is_multigraph():
    for d in data.values():
     line += (make_str(t) + delimiter)
   else:
    line += (make_str(t) + delimiter)
  if (not directed):
   seen.add(s)
  (yield line[:(- len(delimiter))])

def generate_adjlist ( G , delimiter = ' ' ) : directed = G . is_directed ( ) seen = set ( ) for ( s , nbrs ) in G . adjacency ( ) : line = ( make_str ( s ) + delimiter ) for ( t , data ) in nbrs . items ( ) : if ( ( not directed ) and ( t in seen ) ) : continue if G . is_multigraph ( ) : for d in data . values ( ) : line += ( make_str ( t ) + delimiter ) else : line += ( make_str ( t ) + delimiter ) if ( not directed ) : seen . add ( s ) ( yield line [ : ( - len ( delimiter ) ) ] )
generate a single line of the graph g in adjacency list format .