def gnr_graph(n, p, 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 (seed is not None):
  random.seed(seed)
 G = empty_graph(1, create_using)
 G.name = ('gnr_graph(%s,%s)' % (n, p))
 if (n == 1):
  return G
 for source in range(1, n):
  target = random.randrange(0, source)
  if ((random.random() < p) and (target != 0)):
   target = next(G.successors(target))
  G.add_edge(source, target)
 return G

def gnr_graph ( n , p , 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 ( seed is not None ) : random . seed ( seed ) G = empty_graph ( 1 , create_using ) G . name = ( 'gnr_graph(%s,%s)' % ( n , p ) ) if ( n == 1 ) : return G for source in range ( 1 , n ) : target = random . randrange ( 0 , source ) if ( ( random . random ( ) < p ) and ( target != 0 ) ) : target = next ( G . successors ( target ) ) G . add_edge ( source , target ) return G
return the growing network with redirection digraph with n nodes and redirection probability p .