rustworkx.directed_barabasi_albert_graph#
- directed_barabasi_albert_graph(n, m, seed=None, initial_graph=None)#
Generate a random graph using Barabási–Albert preferential attachment
A graph is grown to $n$ nodes by adding new nodes each with $m$ edges that are preferentially attached to existing nodes with high degree. All the edges and nodes added to this graph will have weights of
None
. For the purposes of the extension algorithm all edges are treated as weak (meaning directionality isn’t considered).The algorithm performed by this function is described in:
A. L. Barabási and R. Albert “Emergence of scaling in random networks”, Science 286, pp 509-512, 1999.
- Parameters:
n (int) – The number of nodes to extend the graph to.
m (int) – The number of edges to attach from a new node to existing nodes.
seed (int) – An optional seed to use for the random number generator
initial_graph (PyDiGraph) – An optional initial graph to use as a starting point.
star_graph()
is used to create anm
node star graph to use as a starting point. If specified the input graph will be modified in place.
- Returns:
A PyDiGraph object
- Return type: