Skip to main content
`Ctrl`+`K`

# barabasi_albert_graph

barabasi_albert_graph(n, m, seed=None, initial_graph=None, *, create_using=None)

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

  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.

    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 `initial_graph` is used. If None, starts from a star graph on (m+1) nodes.

    create_using Graph constructor, optional (default=nx.Graph)

      Graph type to create. If graph instance, then cleared before populated. Multigraph and directed types are not supported and raise a `NetworkXError`.

  Returns:
    G Graph
  Raises:
    NetworkXError

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

  References

  [1]

  A. L. Barabási and R. Albert “Emergence of scaling in random networks”, Science 286, pp 509-512, 1999.