Guest
Sign in to keep your graphs and progress.
Select an algorithm and generate steps to begin visualization
The rich get richer: how hubs grow
Grows a network one vertex at a time: each newcomer links to m vertices picked in proportion to their degree, so hubs emerge and the degrees follow a power law
The drawn edges are the starting network. Vertices without edges join one by one, in label order.
Select an algorithm and generate steps to begin visualization
The Barabási–Albert model grows a random network one vertex at a time. Each newcomer links to m existing vertices, picked with probability proportional to their degree, so a vertex with twice as many links is twice as likely to win the next one. Albert-László Barabási and Réka Albert proposed it in 1999 to explain why so many real networks, from the web to citation and social networks, have a few huge hubs and a long tail of vertices with few links. Two ingredients are enough: growth, because the network keeps getting new vertices, and preferential attachment, the rich get richer. The resulting degree distribution follows a power law, P(k) ∝ k^-3, unlike the bell shape of a purely random graph, which is why such networks are called scale-free.
The drawn edges form the seed network, a triangle in the example, and every vertex without edges joins later, one by one in label order. When a vertex arrives, the visualizer computes each existing vertex's chance, its degree divided by the sum of all degrees, writes it in a badge, then draws m distinct targets with those chances and adds the new edges. Vertex size follows degree, so the hubs swell as the network grows, and the panel draws the degree distribution. With m = 2 and 13 vertices joining the triangle A, B, C, the final network has 16 vertices and 29 edges. B ends with 10 links, D with 7 and A with 6, while 9 vertices keep only the 2 links they arrived with. The mean degree is 3.6, yet most vertices are below it: a long tail in miniature.
The model is the standard explanation and generator for scale-free networks. It is used to create realistic synthetic graphs for testing algorithms and databases, to study how the internet, power grids and protein interaction networks respond to failures and attacks, since scale-free networks shrug off random failures but break quickly when their hubs are removed, and to model how epidemics and rumours spread, where hubs act as super-spreaders and vaccinating them helps most. Citation counts, where cited papers attract more citations, and follower counts on social platforms behave the same way. NetworkX, igraph and other libraries provide a barabasi_albert_graph generator, and extensions add fitness, ageing or clustering to match particular networks better.
Growth plus preferential attachment, one newcomer at a time.
BarabasiAlbert(G0, n, m):
G = G0 // the seed network
while G has fewer than n vertices:
P(u) = deg(u) / sum of all degrees, for every u in G
T = m distinct vertices drawn with the chances P
add a new vertex v and an edge from v to every vertex of T
return GDrawing from a list that holds each vertex once per edge end gives the same chances in O(1) per draw, since a vertex of degree k appears k times. That keeps the model at O(n · m). The visualizer computes the chances explicitly so that each newcomer's odds can be shown.
The example loaded on this page, with m = 2.
Example graph: A triangle A, B, C as the seed and 13 vertices D to P without edges, which join in that order.
16 vertices and 29 edges. The hubs are B with 10 links, D with 7 and A with 6, while 9 vertices keep only the 2 links they arrived with. The mean degree is 3.6, yet most vertices lie below it.
Time: O(n · m) · Space: O(n · m)
Each newcomer adds m edges. With the list of edge ends, each draw costs O(1), with a redraw when a vertex repeats, so the model runs in O(n · m) time and stores its n · m edges. Computing every chance for each newcomer, as the visualizer does, costs O(n) per vertex and O(n²) in all, which is fine for small graphs.
Other random graph models.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Erdős–Rényi | Edges should be independent, each present with probability p. Degrees follow a Poisson distribution with no hubs. | O(n + m) |
| Configuration model | A given degree sequence must be matched exactly, for instance one measured on real data. Havel–Hakimi checks that the sequence is graphical. | O(m) |
| Watts–Strogatz | High clustering and short paths are wanted, without hubs. A ring lattice is rewired at random. | O(n · k) |
Related algorithms: Havel-Hakimi, Clustering Coefficient, PageRank, k-Core Decomposition, Independent Cascade (Spread)
Built by Mohammed Islam Hadjoudj · Work with me