dynamicalab.generators.generalized_PA_model

dynamicalab.generators.generalized_PA_model(nu, p, N, directed=False, max_step=10000.0)[source]

Generates a network using the generalized preferential attachment model. The process goes as follows:

  1. Initialize the network with two connected nodes.
  2. Choose a birth event with probability p, or a growing event with probability 1-p. Then:
    1. If a birth event, choose and place a new node in the network.
    2. If a growth event, choose an existing node proportionnal to its total degree powers nu.
  3. Choose an existing node following 2b.
  4. Connect the node from step 2 with node from step 3.
  5. Repeat steps 2,3,4 until the number N is reached.

Parameters

nu : float
Kernel power.
p : float
Birth probability.
N : int
Number of nodes. The estimated steps to reach N nodes is N/p.
directed : bool : (default=False)
Construct a directed network. If true, new edges are connected toward older nodes and the output is a nx.Digraph
max_step : int : (default=1e4)
Maximum number of events before the algorithm ends. This does not apply if the desired number of nodes is reached.

Returns

nx.Digraph or nx.Graph
The resulting graph.

Raise

ValueError 
Occurs if the birth probability p is smaller or equal to zero.

Example

import dynamicalab as dlb

nu = 1.0
p = 1.0
N = 40
G = dlb.generalized_PA_model(nu, p, N)

Note

See Young et al., 2018 for an intensive description of the model.

../../../_images/zoo.png

Example of networks for p=1. Figure inspired of Young et al., 2018.