NetworkX

Previous topic

random_clustered_graph

Next topic

gnr_graph

gn_graph

gn_graph(n, kernel=None, create_using=None, seed=None)[source]

Return the GN digraph with n nodes.

The GN (growing network) graph is built by adding nodes one at a time with a link to one previously added node. The target node for the link is chosen with probability based on degree. The default attachment kernel is a linear function of degree.

The graph is always a (directed) tree.

Parameters :

n : int

The number of nodes for the generated graph.

kernel : function

The attachment kernel.

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

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

Examples

>>> D=nx.gn_graph(10)    # the GN graph
>>> G=D.to_undirected()  # the undirected version

To specify an attachment kernel use the kernel keyword

>>> D=nx.gn_graph(10,kernel=lambda x:x**1.5) # A_k=k^1.5