def gn_graph(n, kernel=None, create_using=None, seed=None):
 if (create_using is None):
  create_using = nx.DiGraph()
 elif (not create_using.is_directed()):
  raise nx.NetworkXError('Directed Graph required in create_using')
 if (kernel is None):
  kernel = (lambda x: x)
 if (seed is not None):
  random.seed(seed)
 G = empty_graph(1, create_using)
 G.name = 'gn_graph({})'.format(n)
 if (n == 1):
  return G
 G.add_edge(1, 0)
 ds = [1, 1]
 for source in range(2, n):
  dist = [kernel(d) for d in ds]
  target = discrete_sequence(1, distribution=dist)[0]
  G.add_edge(source, target)
  ds.append(1)
  ds[target] += 1
 return G

def gn_graph ( n , kernel = None , create_using = None , seed = None ) : if ( create_using is None ) : create_using = nx . DiGraph ( ) elif ( not create_using . is_directed ( ) ) : raise nx . NetworkXError ( 'Directed Graph required in create_using' ) if ( kernel is None ) : kernel = ( lambda x : x ) if ( seed is not None ) : random . seed ( seed ) G = empty_graph ( 1 , create_using ) G . name = 'gn_graph({})' . format ( n ) if ( n == 1 ) : return G G . add_edge ( 1 , 0 ) ds = [ 1 , 1 ] for source in range ( 2 , n ) : dist = [ kernel ( d ) for d in ds ] target = discrete_sequence ( 1 , distribution = dist ) [ 0 ] G . add_edge ( source , target ) ds . append ( 1 ) ds [ target ] += 1 return G
return the growing network digraph with n nodes .