NetworkX

Previous topic

networkx.generators.directed.gn_graph

Next topic

networkx.generators.directed.gnc_graph

networkx.generators.directed.gnr_graph

networkx.generators.directed.gnr_graph(n, p, create_using=None, seed=None)

Return the GNR digraph with n nodes and redirection probability p.

The GNR (growing network with redirection) graph is built by adding nodes one at a time with a link to one previously added node. The previous target node is chosen uniformly at random. With probabiliy p the link is instead “redirected” to the successor node of the target. The graph is always a (directed) tree.

Parameters :

n : int

The number of nodes for the generated graph.

p : float

The redirection probability.

create_using : graph, optional (default DiGraph)

Return graph of this type. The instance will be cleared.

seed : hashable object, optional

The seed for the random number generator.

References

[R109]P. L. Krapivsky and S. Redner, Organization of Growing Random Networks, Phys. Rev. E, 63, 066123, 2001.

Examples

>>> D=nx.gnr_graph(10,0.5)  # the GNR graph
>>> G=D.to_undirected()  # the undirected version