From compartments to a graph
The classic SIR model — Susceptible → Infected → Recovered — assumes a well-mixed population: every susceptible person is equally likely to meet every infected person, so the whole epidemic is captured by two numbers, the transmission rate beta and the recovery rate gamma. That assumption is a convenient fiction. Real people don't mix uniformly; they have a fixed, lumpy set of contacts — a household, a workplace, a handful of friends — and that structure is a graph: people are nodes, contacts are edges, and the epidemic only travels along edges that exist.
Running SIR on a network instead of a compartment model doesn't just add realism for its own sake — it changes the qualitative outcome. Two populations with identical average number of contacts can have completely different outbreak sizes, because what matters is not the average degree but the shape of the degree distribution: how unevenly connections are spread across people.
The rules, and the threshold that depends on degree variance
At each time step, every infected node transmits along each of its edges to a susceptible neighbour with probability related to beta, and recovers with probability gamma. That's the entire model — no differential equations required, just a graph and two coin flips per edge per step:
for each infected node i:
for each neighbour j of i:
if j is susceptible and random() < beta:
j becomes infected
if random() < gamma:
i becomes recovered (removed from the infectious pool)
In a well-mixed population the epidemic threshold is the familiar R0 = beta/gamma > 1. On a network, the correct threshold derived from the configuration model is R0 = beta<k²> / (gamma<k>), where <k> is the mean degree and <k²> is the mean of the squared degree. Because <k²> grows with the variance of the degree distribution, two networks with the same average number of contacts can sit on opposite sides of the threshold if one has a few extremely well-connected hubs and the other doesn't.
Hubs, and the friendship paradox
There's a neat statistical reason hubs dominate outbreaks even before you account for their raw contact count: the friendship paradox. On average, your friends have more friends than you do — a consequence of size-biased sampling, since high-degree nodes appear in many people's contact lists simply by virtue of having many contacts. Pick a random edge in the network and follow it, and you land on a higher-than-average-degree node more often than chance would suggest.
For an epidemic this means infection doesn't spread uniformly outward — it disproportionately reaches hubs early, and once a hub is infected it re-transmits to dozens of neighbours at once. This is exactly why targeted immunization of high-degree nodes is so much more efficient at stopping an outbreak than immunizing a random fraction of the population: removing a handful of hubs can collapse <k²> and push a network back below threshold.
Random, small-world and scale-free — three regimes
The simulation on this page lets you switch between three canonical network models, and each produces a visibly different epidemic curve. An Erdős–Rényi random graph has a Poisson degree distribution — most nodes have close to the average degree, few extreme hubs — so its network-corrected threshold is close to the classical beta/gamma one. A Watts–Strogatz small-world network starts as a ring lattice and rewires a few edges at random, which collapses the path length between distant nodes (the famous "six degrees") without changing the degree distribution much, so outbreaks reach the whole population fast but the threshold stays similar to the random case.
A Barabási–Albert scale-free network is the interesting case: new nodes attach preferentially to already-popular ones ("rich get richer"), producing a power-law degree distribution with a heavy tail of hubs. Pastor-Satorras and Vespignani showed in 2001 that for a degree exponent between 2 and 3 — the range most cited real contact and social networks fall into — the second moment <k²> diverges as the network grows, driving the epidemic threshold toward zero. In the idealized infinite limit, essentially any nonzero transmission rate can sustain an outbreak; in finite real networks a small positive threshold survives, but it is far lower than a random-graph estimate of the same average degree would suggest.
Frequently asked questions
Why does the same R0 give different outbreaks on different networks?
Because R0 = beta/gamma assumes everyone contacts everyone equally. On a graph the real threshold is beta·⟨k²⟩/(gamma·⟨k⟩), which depends on the variance of the degree distribution, not just its mean. Two networks with identical average degree but different spread in that degree can have wildly different outbreak sizes.
What is the friendship paradox and why does it matter for epidemics?
On average, your contacts have more contacts than you do, because high-degree hubs appear in many people's contact lists. A random infected node is therefore more likely than average to be, or to be adjacent to, a hub, which is why real outbreaks accelerate faster than a naive well-mixed model predicts.
Does a scale-free network ever have a true epidemic threshold?
In the idealized infinite-size limit, no: because ⟨k²⟩ diverges for a degree exponent between 2 and 3, the threshold collapses to zero and any nonzero beta can spread. Real contact networks are finite, so a small positive threshold reappears, but it stays much lower than a random-graph model of the same average degree would predict.
Try it live
Everything above runs in your browser — open Viral Network Spread and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Viral Network Spread simulation