This is a genuine network epidemic model, not a free-roaming population: every individual is a fixed node and disease can only travel along a real contact edge, exactly as it would through a household, workplace or friendship graph. Each simulated step, every infectious node rolls its per-contact transmission probability β independently against every susceptible neighbour it is actually connected to — a node with no edge to an infectious node cannot be infected, no matter how close it is drawn on screen. Infectious nodes recover (and gain lasting immunity) with probability γ per step.
Two different graphs run in parallel with the identical β, γ and starting infected set, so the only thing that differs is contact structure: the left graph is a random Erdos-Renyi network (edges placed uniformly at random), the right is a Watts-Strogatz small-world network (a ring lattice where most contacts are local neighbours, with a few long-range shortcuts rewired in). Both are built with the same total number of edges, so the comparison isolates topology, not contact count. The small-world graph's short average path length usually lets an outbreak reach every corner of the network faster and larger than the same edge budget spent on a purely random graph, or vice versa depending on the random rewiring — watch the two Infectious curves in the chart diverge.
The social distancing slider removes that fraction of edges from both networks at reset time, simulating a real reduction in daily contacts (working from home, closed venues) rather than a magic speed penalty — fewer edges means fewer chances for the disease to jump from an infectious node to a susceptible one.
- Population N — number of nodes in each network.
- Initial infected — the same node indices are seeded Infectious in both networks, for a fair comparison.
- Social distancing — percentage of contact edges removed from both graphs before the run starts.
- Transmission β — probability an infectious node infects a given susceptible neighbour in one step.
- Recovery rate γ — probability an infectious node recovers in one step.