GenPrefAttach(Nodes, NodesOutDeg, Rnd=TRnd)

Generates an undirected graph with a power-law degree distribution using Barabasi-Albert model of scale-free graphs.


  • Nodes: int (input)

    The number of nodes desired.

  • NodeOutDeg: int (input)

    The out degree of each node desired.

  • Rnd: TRnd (input)

    Random number generator.

Return Value:

  • undirected graph

    A undirected graph representing the power-law degree distribution.

The function implements a Barabasi-Albert model of scale-free graphs and generates graphs with a power-law degree distribution. See: Emergence of scaling in random networks by Barabasi and Albert. URL:

The following example shows how to use GenPrefAttach():

import snap

Rnd = snap.TRnd()
UGraph = snap.GenPrefAttach(100, 10, Rnd)
for EI in UGraph.Edges():
    print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())

Previous topic


Next topic


This Page