Preferential Attachment

Module 5: Complex Networks

Neither the random graph nor the small-world model produces hubs. Many real networks have heavy-tailed degree distributions, sometimes close to a power law \(p_k \sim k^{-\gamma}\) (Barabasi and Albert 1999; newman2003structure?). Barabási and Albert proposed that two ingredients generate such a distribution: growth and preferential attachment (Barabasi and Albert 1999).

The Barabási-Albert model

  1. Start with a small network of \(m_0 \ge m\) nodes.
  2. At each step add one new node with \(m\) edges.
  3. Each new edge goes to an existing node \(i\) with probability proportional to its degree, \[ \Pi(k_i) = \frac{k_i}{\sum_j k_j}. \]
  4. Repeat until the network has \(N\) nodes.

The mean degree tends to \(\langle k \rangle = 2m\).

Key results

  • In the limit of large \(N\), the degree distribution is \[ p_k = \frac{2m(m+1)}{k(k+1)(k+2)} \sim k^{-3}, \qquad k \ge m, \] so the exponent is \(\gamma = 3\) (newman2003structure?; Newman 2018).
  • The degrees of the oldest nodes grow like \(\sqrt{t}\), so the largest degree grows like \(k_{\max} \sim m\sqrt{N}\) (Barabasi and Albert 1999; Newman 2018).
  • With \(\gamma = 3\) the second moment diverges logarithmically. Summing \(k^2 p_k\) up to \(k_{\max}\) gives \(\langle k^2 \rangle \approx m(m+1)\ln N\) for large \(N\). The degree variance \(\langle k^2 \rangle - \langle k \rangle^2\) therefore grows without bound as \(N\) grows, even though the mean stays at \(2m\).
  • The average path length is small, and the clustering is low and decreases with \(N\) (newman2003structure?).

The divergence of \(\langle k^2 \rangle\) drives two results of this module: the robustness to random failure in Robustness and Percolation and the vanishing epidemic threshold in Epidemic Threshold. Keep in mind that the divergence is slow: at realistic sizes \(\langle k^2 \rangle\) is large but finite.

Implementation

In NetworkX, nx.barabasi_albert_graph(n, m) adds nodes one at a time, each with m edges attached by preferential attachment.

import matplotlib.pyplot as plt
import networkx as nx
import numpy as np

SEED = 7

G_sf = nx.barabasi_albert_graph(n=200, m=2, seed=SEED)
pos = nx.spring_layout(G_sf, seed=SEED)
size = [5 * d for _, d in G_sf.degree()]
nx.draw(G_sf, pos=pos, node_size=size, node_color="lightgreen", edge_color="gray", alpha=0.8)
plt.title("Barabási-Albert graph, N = 200, m = 2")
plt.show()

Degree distribution and second moment

Figure 1 compares the empirical distribution with the exact formula. Use logarithmic bins or the complementary cumulative distribution for real data; here the formula lets you compare point by point.

Figure 1: Left: degree distribution of one Barabási-Albert graph (N = 20000, m = 2) against p_k = 2m(m+1)/(k(k+1)(k+2)). Right: second moment of the degree against N, with the approximation m(m+1) ln N (dashed).

The approximation \(m(m+1)\ln N\) follows the simulated values closely over two decades of \(N\). The small deviations come from the approximations in the sum (the lower limit \(k = m\) and the cutoff at \(k_{\max}\)) and from fluctuations of the largest degrees.

Exercise

Compute the mean and the variance of the degree for nx.barabasi_albert_graph(N, 2) with \(N = 10^3\) and \(N = 10^4\). Which one changes?

for N in [1_000, 10_000]:
    k = np.array([d for _, d in nx.barabasi_albert_graph(N, 2, seed=SEED).degree()])
    print(N, k.mean().round(2), k.var().round(1))

The mean stays close to \(2m = 4\). The variance grows with \(N\), as the logarithmic divergence of \(\langle k^2 \rangle\) predicts.

  • nx.powerlaw_cluster_graph(n, m, p, seed=...) adds a triangle-closing step to preferential attachment, which raises the clustering.
  • nx.scale_free_graph(n, seed=...) returns a directed multigraph.
  • nx.configuration_model(degree_sequence, seed=...) builds a random graph with any degree sequence you choose.

For this course, nx.barabasi_albert_graph is usually the best starting point.

What’s Next?

The next page compares the three models with the same summary metrics.

Comparing Graph Models

References

Barabasi, Albert-Laszlo, and Reka Albert. 1999. “Emergence of Scaling in Random Networks.” Science 286 (5439): 509–12. https://doi.org/10.1126/science.286.5439.509.
Newman, Mark. 2018. Networks. 2nd ed. Oxford University Press.