networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturns
barabasi_albert_graph(n, m, seed=None, initial_graph=None)

A graph of $n$ nodes is grown by attaching new nodes each with $m$ edges that are preferentially attached to existing nodes with high degree.

Parameters

n : int

Number of nodes

m : int

Number of edges to attach from a new node to existing nodes

seed : integer, random_state, or None (default)

Indicator of random number generation state. See Randomness<randomness> .

initial_graph : Graph or None (default)

Initial network for Barabási–Albert algorithm. It should be a connected graph for most use cases. A copy of :None:None:`initial_graph` is used. If None, starts from a star graph on (m+1) nodes.

Raises

NetworkXError

If m does not satisfy 1 <= m < n , or the initial graph number of nodes m0 does not satisfy m <= m0 <= n .

Returns

G : Graph

Returns a random graph using Barabási–Albert preferential attachment

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/generators/random_graphs.py#614
type: <class 'function'>
Commit: