🦠 Viral Spread on Contact Network

An SIR epidemic on a heterogeneous contact network. Hubs spread virus faster. Adjust transmission rate β, recovery γ, and network type (random/scale-free/small-world).

NetworksInteractive
Blue=Susceptible · Red=Infected · Green=Recovered · P pause · R reset

How it Works

The simulation builds a contact network with the chosen topology and runs a discrete-time SIR epidemic on it. Each time step, each infected node attempts to transmit to each susceptible neighbor with probability β·dt. Each infected node recovers with probability γ·dt per step.

Node sizes are proportional to degree (number of connections). Scale-free networks have a few very high-degree hubs that act as super-spreaders. The epidemic curve is shown in the top-right corner.

SIR on network: per step, node i (Infected) infects neighbor j (Susceptible) with prob β·dt
Node i recovers: prob γ·dt per step
R₀ = β/γ · ⟨k²⟩/⟨k⟩ (heterogeneous network correction)
Scale-free: P(k) ∝ k⁻², grown by preferential attachment

Frequently Asked Questions

What is the SIR model?

The SIR model divides a population into Susceptible (S), Infected (I), and Recovered (R) compartments. People move from S→I at rate β·S·I/N, and from I→R at rate γ·I, capturing the essential dynamics of many infectious diseases.

What is a contact network in epidemiology?

A contact network represents individuals as nodes and their social contacts as edges. Disease spreads along edges from infected to susceptible nodes. The network structure profoundly influences epidemic dynamics, speed, and final size.

What is a scale-free network?

A scale-free network has a degree distribution that follows a power law P(k) ∝ k⁻ᵞ. Most nodes have few connections, but rare hubs have very high degree. The internet and many social networks are approximately scale-free.

Why do hubs accelerate epidemic spread?

Hubs (high-degree nodes) connect to many others. When a hub becomes infected, it can rapidly infect many neighbors. Epidemics on scale-free networks spread faster and have no epidemic threshold in the infinite network limit.

What is the basic reproduction number R₀?

R₀ = β/γ is the average number of secondary infections caused by one infected individual in a fully susceptible population. If R₀ > 1 an epidemic can occur; if R₀ < 1 the infection dies out.

What is a small-world network?

A small-world network (Watts-Strogatz model) has high local clustering like a lattice but short average path lengths like a random graph. Most pairs of nodes are connected by a surprisingly short chain — the 'six degrees of separation'.

How does vaccinating hubs affect epidemic spread?

Targeted vaccination of high-degree nodes (hubs) is far more effective on scale-free networks than random vaccination. Removing hubs fragments the network into smaller components, greatly reducing epidemic spread even at low vaccination coverage.

What is herd immunity?

Herd immunity occurs when a sufficient fraction of the population is immune (recovered or vaccinated) so that the effective reproduction number R_eff < 1. For a homogeneous population, the threshold is 1 - 1/R₀.

How does network clustering affect epidemics?

High clustering creates local cliques where the virus can spread quickly among tight-knit groups but may then become locally exhausted. Clustering can slow global spread by reducing the number of long-range transmission pathways.

What is superspreading in epidemics?

Superspreading occurs when a single infected individual infects many more than average (like a hub in a contact network). Superspreading events (SSEs) account for a disproportionate fraction of transmission and are characteristic of heterogeneous contact networks.

About this simulation

Two randomly seeded nodes start Infected on a network you build with one of three real graph-generation algorithms — Erdos-Renyi random, Barabasi-Albert preferential attachment, or Watts-Strogatz rewiring — then a discrete-time SIR loop rolls transmission and recovery dice for every infected node's neighbours each step. Node size is drawn proportional to degree, so watching a big scale-free hub light up red shows exactly why real-world super-spreaders matter so much for how fast an epidemic takes off.

🔬 What it shows

A force-directed graph of blue (Susceptible), red (Infected) and green (Recovered) nodes with edges that flash red during active transmission, plus a live S/I/R epidemic curve chart in the corner.

🎮 How to use

Pick a Network Type, tune Transmission β, Recovery γ and Nodes count, click Rebuild Network to regenerate the graph, and press P/R to pause/reset.

💡 Did you know?

On truly infinite scale-free networks there is no epidemic threshold at all — even an infinitesimally small transmission rate can eventually spread through the whole population, because a few nodes have effectively unlimited connections.

Frequently asked questions

How does the simulation decide who gets infected each step?

For every currently Infected node, the code loops over its adjacency list and flips a random number against beta for each Susceptible neighbour, infecting it if the roll succeeds - a direct discretisation of the SIR transmission term.

Why do some nodes have a white outline?

Nodes whose degree exceeds 60% of the network's maximum degree get a white stroke, visually flagging the hubs most likely to become super-spreaders once infected.

What is different about how the three network types are built?

Random wires every pair of nodes independently with fixed probability, Scale-free grows the network one node at a time attaching new links proportional to existing degree (preferential attachment), and Small-world starts from a ring lattice and randomly rewires a fraction of edges.

Why does R0 change when I move the sliders?

The stat panel computes R0 as beta divided by gamma directly from the current slider values every step, so raising transmission or lowering recovery immediately pushes R0 higher, reflecting a stronger tendency for the epidemic to grow.

Why do edges near a hub turn red before the rest of the network?

An edge is coloured red only when it connects a currently Infected node to a Susceptible one, so a high-degree hub becoming infected temporarily reddens many more edges at once than a low-degree node would.