Each city runs SIR (γ = 1/10 per day); a share m of people moves to each neighbouring city per day, carrying their state.
Epidemic ModelingCore models
Module 4Spatio-temporal models
Epidemics happen in places. We link cities by travel (metapopulation models), put people on contact networks, let infection spread as a wave across continuous space, and use matrix norms to bound growth without solving everything. Along the way: effective distance, imported sparks, excess degree and hubs, clustering, wave speed, borders, long jumps, transient growth and the critical patch size.
Key ideas, one per episode
- Ep. 13Travel decides when an epidemic arrives, not how big it gets; arrival follows effective distance, not the map.
- Ep. 14On networks the threshold depends on excess degree: hubs lower it and speed spread, clustering slows it.
- Ep. 15Reaction plus diffusion makes waves with speed 2√(D r); borders, drift and long jumps reshape them.
- Ep. 16Any matrix norm below one proves an outbreak dies out; the spectral radius tells the long run, norms the short run.
Textbook: Chapter 4 of T. Lazebnik, Epidemic Modeling: Principles, Algorithms, and Applications (Academic Press, 2026). The episodes and slides follow the chapter’s topics in our own words, figures and simulations; nothing is copied from the book.
Watch
4 short episodes for this module. Pick one from the list, and open the transcript to read along: each timestamp plays the episode from there. The narration is generated with a voice clone of Teddy, used with his permission.
Episode 13 · 5:42
Cities linked by travel
Space enters the model: cities linked by travel.
Travel decides when an epidemic arrives, not how big it gets; arrival follows effective distance, not the map.
TranscriptEpisode 13
When will it arrive?. An outbreak starts in one city. When does it reach the next city, and the one after that? Today, space enters the model, starting with cities linked by travel. And here's where we're heading: travel decides when an epidemic arrives far more than the map does.
Patches linked by travel. Split the map into patches: cities, districts, regions. Inside each patch, people mix well, so each patch runs its own S I R. Patches are linked by movement. A matrix M holds the travel rates: m p q is the share of patch p's people who travel to patch q each day. Travelers carry their state with them. A susceptible traveler arrives susceptible. An infected one arrives infected, and seeds the next city. This is the flux, or migration, form. People really relocate, and every compartment flows along the links. The total population stays the same; only where people are changes.
Moving people or moving risk. There's a second way to link patches. Most travel is commuting: people visit another city during the day and come home at night. Then we keep everyone at home and let infection pressure travel instead. The force of infection in patch p adds up contact with infected people from every patch, weighted by how much the two patches mix. Moving people, or moving risk. Pick the one that matches your data: migration records, or commuting and visit data.
Two clocks: growth and travel. Let's see what travel does. Five cities in a row, each with R₀ of three, each linked only to its neighbors. The first city has the outbreak. With very little travel, three people in ten thousand a day, the waves come one after another. The last city peaks on day one hundred thirty seven, eighty seven days after the first. With a lot of travel, one person in ten a day, all five cities peak within two days of each other, around day fifty eight. And either way, every city ends with about ninety four percent infected. Travel changes the timing, not the total. Two clocks are racing: how fast the epidemic grows inside a city, and how fast people move between cities. Weak travel gives a chain of local epidemics. Strong travel merges them into one.
Effective distance. Now a more realistic map: eight cities of different sizes. Travel falls off with distance, plus one air link between the two big cities. The outbreak starts in the big city on the left. Its nearest neighbor is reached on day twenty four. The other big city, near the far end, across the air link: day ten. Distance on the map explains almost none of the arrival times. R squared is 0.05. So measure distance by travel instead. Brockmann and Helbing defined an effective distance: one minus the log of the share of travelers going from one city to the next, added up along the best route. With effective distance, arrival times fall on a straight line: R squared of 0.99. The epidemic moves like a wave, in travel space, not on the map.
Imported sparks. Travel can also keep an outbreak going where it would die out alone. Take a small town where each case infects only 0.8 others. On its own, a few cases fizzle: less than half a percent of the town is ever infected. Now let one tenth of the town's contacts be with visitors from a big city, where R₀ is two. The town ends with thirty six percent infected. Locally, R₀ is below one, yet the town is hit hard, because sparks keep arriving. So don't only ask if R₀ is above one. Ask how often sparks arrive.
R0 of a network of patches. So what is R₀ for a whole network of patches? The next generation matrix from Module three answers it: the local reproduction numbers, combined through the mixing matrix. R₀ is its dominant eigenvalue. Take one hot city where each case infects 1.6 people, and four cool cities at 0.8. On its own, the hot city sustains an outbreak. Mix them, and the hot city's cases spend part of their contacts in cool cities. Mix half of all contacts, and R₀ falls to 1.1. Mix three quarters, and it reaches one. Now flip it. Five cities just below one, at 0.95. Turn one into a hotspot at 1.6, with thirty percent mixing, and the whole network goes above one, to 1.27. One hotspot can carry a region.
Border closures. Real models add more: different parameters per city, so some cities export infection and others import it; commuting that differs on weekdays and weekends; and travel that changes over time. Like a border closure. Two cities linked by travel. Cut the travel to one twentieth on day seven, and the second city's outbreak arrives four days later, and peaks a week later. Cut it on day zero, and the peak comes two weeks later. Cut it on day twenty, after the virus has arrived, and it buys three days. And every time, the second city still ends with ninety four percent infected. A closure buys time: to prepare, to treat, to vaccinate. It doesn't buy immunity.
Recap. So: patches with their own S I R, linked by travel. Weak links give a chain of waves; strong links synchronize them. Arrival follows effective distance, and imported sparks can keep places burning that couldn't burn on their own. Next time, we zoom in from cities to people: epidemics on networks of contacts.
Same contacts, different epidemics. Two towns. In both, people have four contacts on average. In one, the epidemic peaks after about a hundred days. In the other, in under a month. The difference is who is connected to whom.
Contact networks and T. In a contact network, people are nodes, and an edge is a chance to infect: a household, the person at the next desk, a weekly meeting. Infection moves along edges. An infected person infects each susceptible neighbor at a rate, tau, and recovers at rate gamma. So every edge has a transmissibility, T: the chance it transmits before the infected end recovers. T equals tau over tau plus gamma. In our runs, one third.
The percolation picture. Now a beautiful shortcut. Flip a weighted coin for every edge: with probability T, it would transmit if it got the chance. Keep those edges, and delete the rest. A large outbreak is possible only if the kept edges form one giant connected cluster. That links epidemics to percolation, a classic problem in physics. For final sizes on random networks, the percolation picture is close to exact. It says nothing about timing, so for peaks and speed we still simulate.
Excess degree and the threshold. When does the giant cluster appear? When T, times the mean excess degree, is above one. Excess degree is how many other contacts a person has when you reach them by following an edge. And following edges is exactly what an infection does. The catch: edges lead to well-connected people more often. In our hub-heavy network, people have about four contacts on average, but the person at the end of a random edge has more than eleven. Your friends have more friends than you do. So the threshold drops. A random network with four contacts on average needs T above a quarter. The hub-heavy one, with the same average, needs T above about one in ten. With T of one third, both can take off. But the hub network peaks around day twenty seven, against day one hundred five for the random one, and infects half the town instead of forty four percent.
Hubs first. Look at who gets infected over time. In the first week, new cases on the hub network have about ten contacts each. By the tenth week, fewer than four. Hubs are infected early, and they spread fast. Then the epidemic runs out of hubs and slows down. That's one reason early growth can fool a forecast.
Clustering. Now clustering. In real life, your friends often know each other. That makes triangles. Triangles waste transmissions. By the time you could infect your friend's friend, your friend may already have done it. Compare two networks where everyone has exactly four contacts. One is wired at random. In the other, neighbors share friends. With T of one half, the random one takes off in sixty nine percent of runs, and infects eighty five percent of the town. The clustered one takes off in only thirteen percent of runs, and even then infects about twelve percent. Same number of contacts. A very different epidemic.
Diseases you can catch again. For diseases you can catch again, like S I S, the question is whether infection keeps circulating. There, a common approximation makes the threshold spectral: tau over gamma has to beat one over the largest eigenvalue of the network's adjacency matrix. That eigenvalue is driven by dense cores. For our hub network it's about thirteen, for the random one about five. A tight core keeps reinfecting itself.
Interventions on the graph. Networks make interventions concrete. Vaccination removes nodes. Distancing removes edges. Contact tracing follows the edges of each case. On the hub network, with T of one half, almost half the town is infected without vaccination. Vaccinate twenty percent of people at random, and it's still twenty seven percent. Vaccinate the best-connected twenty percent, and the epidemic is gone: under one in a thousand. But that needs the whole contact network, which nobody has. A clever trick works without it. Pick random people, and vaccinate one of their friends. Friends tend to be hubs. Cohen and colleagues called it acquaintance immunization. With twenty percent, the attack rate falls under four percent.
Middle paths and when to use networks. Between simulating every person and assuming everyone mixes, there are middle paths: tracking people by their number of contacts, or equations that follow whether each edge has transmitted yet. Use networks when contact structure matters: superspreading, households, targeted interventions. They're harder when the network is unknown or the population is huge. Often, a hybrid works: networks inside patches, and travel between them.
Recap. So: edge transmissibility T, a threshold set by excess degree, hubs infected first, clustering that slows spread, and interventions as surgery on the graph. Next time, we go continuous: epidemics as waves moving across a map.
A wave you can calculate. Drop ink in water, and it spreads out. Now let the ink multiply as it spreads. That's an epidemic wave crossing a map, and it moves at a speed you can calculate.
Densities, reaction and diffusion. Instead of patches, treat space as continuous. S, I and R become densities: how many susceptible, infected and recovered people live around each point. Every point runs the usual S I R. That's the reaction part. People also move. If each person takes many small random steps, then from far away the crowd spreads out smoothly. That's diffusion. The diffusion coefficient D grows with the square of the step length, divided by the time per step. Reaction plus diffusion: local infection, plus local movement. A reaction diffusion model.
A ring of infection. Here it is in a square town with closed borders, starting from one small seed. Infection grows where it is, and leaks into the neighborhood. The result is a ring of infection moving outward, with recovered people behind it, and susceptible people ahead.
The speed of the front. How fast does the front move? A classic result by Fisher, and by Kolmogorov, Petrovsky and Piskunov, says: two times the square root of D times r. Here r is the early growth rate, beta minus gamma. Movement and growth set the speed together. In our runs, D is one square kilometer per day and r is 0.2. Theory says 0.89 kilometers a day. We measured 0.87. Multiply D by four, and the speed doubles: we measured 1.75, against 1.79 in theory. Movement matters, but through a square root. The measured fronts lag a little behind theory, because a front takes a long time to settle into its final speed.
Borders are assumptions. In continuous space, the edges of the map matter. A boundary condition is an epidemiological assumption. A closed border keeps everyone in: after a hundred fifty days, all of our diffusing crowd is still inside. An absorbing border removes whoever reaches it: forty percent left. A leaky border lets some through: almost sixty percent left. And a border held at a fixed level of infection acts like a constant source, seeding the region again and again. Fit a model with the wrong border, and you'll blame transmission for what was really travel.
Drift along corridors. Movement isn't always random. Commuters flow along corridors. Add a drift, a steady push in one direction, and the wave becomes lopsided. With a drift of 0.4 kilometers a day, the front moves downstream at 1.31, and upstream at only 0.51. Close to theory: the speed, plus or minus the drift.
Uneven landscapes. Landscapes are uneven too. Put in a strip where transmission is too low to sustain spread, like a thinly populated area. A five kilometer strip delays the wave by ten days. A forty kilometer strip, by eighty two days. But in these equations, the strip never stops the wave, because fractions of a person can cross it. With whole people, a wide enough gap can break the chain. The equations can't tell a millionth of a person from zero.
Long jumps. The biggest limit of diffusion: it only allows small steps. Real people also take planes. So replace diffusion with a kernel: how strongly an infected person affects people at each distance. A thin-tailed kernel behaves like diffusion: a steady front, about three quarters of a kilometer a day. A fat-tailed kernel, with rare long jumps, is a different story. New outbreaks pop up far ahead, and the front speeds up: one hundred sixty kilometers by day one hundred, and over a thousand by day one hundred forty. With long jumps, there's no single speed. Arrival is ruled by the rare long trips.
Recap. So: reaction plus diffusion makes waves, with speed two root D r. Borders, drifts and uneven landscapes reshape them, and long jumps break the wave picture. Real models often combine both: smooth local spread, plus travel between hubs. Next time, the last episode of this module: bounding the spread with norms, to know if an outbreak will grow without solving everything.
Will it grow?. A model with a hundred districts. Will the outbreak grow, or die out? You can't eyeball a hundred curves. Today: one number decides it, and cheaper numbers can bound it.
One generation at a time. Start near the beginning of an outbreak, when almost everyone is susceptible. Then new cases in each district depend linearly on the cases in all districts. Write the cases per district as a vector x. One generation later, x becomes A times x. Column q of A says what one case in district q causes, district by district. Growth or decay is set by the spectral radius of A: its largest eigenvalue, in size. Above one, the outbreak grows. Below one, it dies out. It's the next generation matrix again, now in space.
Norms: cheap sizes. But eigenvalues of big matrices can be costly, and often the matrix is only partly known. Norms are cheaper. A norm measures the size of a vector. The one norm is the total number of cases. The infinity norm is the worst district. A matrix norm measures how much a matrix can amplify, at most. The one norm of A is its largest column sum: the most cases that any single case can cause. The infinity norm is its largest row sum: the most pressure any one district can receive.
The guarantee. And here's the key fact: the spectral radius is never bigger than any of these norms. So if any one of them is below one, the outbreak must die out. Guaranteed. Our example: five districts. The largest column sum is 0.95. Every case causes fewer than one case. Decay is proven, without computing a single eigenvalue. The largest row sum is 1.1, so that norm can't decide. The true spectral radius is 0.92. A norm gives a guarantee in one direction only. Starting from a hundred cases, the total falls to about fifty within ten generations.
Short run, long run. Now the twist. The spectral radius tells you the long run. It doesn't tell you what happens first. Take six districts along a travel route. Each case causes half a case at home, and one case in the next district down the line. The spectral radius is one half, so it will die out. But the largest column sum is 1.5. And from a hundred cases, the total climbs to about thirteen hundred sixty by generation eight, before it falls. Both numbers are right. The norm bounds how fast cases can grow in each step. The eigenvalue tells you where it ends. Check only the eigenvalue, and a big transient wave can surprise you. Take the norm of A to the power k, then its k-th root. As k grows, it slowly approaches the spectral radius. That's Gelfand's formula: norms are the short-run view, the eigenvalue is the long run.
Keep and export. Norms also give simple policy rules. Say each case causes a share a at home, and a share b elsewhere, spread over the other districts by travel. Then every column sums to a plus b, and that sum is exactly the spectral radius. Keep 0.7 at home and export 0.2: that's 0.9, and the outbreak decays. Export 0.35 instead: 1.05, and it grows. So you can trade: cut local transmission, or cut exports. What counts is the sum.
Norms in continuous space. Norms work in continuous space too. Measure the infected density with an L two norm. With closed borders, diffusion only smooths. It can never make that norm grow faster than the local growth rate r. In our run, r was 0.2, and the fastest growth we saw was 0.17. With absorbing borders, diffusion even helps, because people carry infection out of the region. A strip of land with absorbing edges sustains an outbreak only if it's wider than a critical size: pi times the square root of D over r. For our numbers, about seven kilometers. At eighty percent of that width, the outbreak shrinks by about eleven percent a day. At a hundred twenty percent, it grows by six percent a day. Just as theory says.
From space to a graph. Finally, going from continuous space back to a graph. Split the map into regions, add up the people in each, and turn flows across borders into travel rates. Fewer regions make a cheaper model, but there's a price. On a line of a hundred twenty kilometers, the wave reaches the far third on day one hundred forty. A graph with three towns gets there on day seventy five. Far too early. Twelve towns: day one hundred fourteen. Forty eight towns: day one hundred thirty six. Each town mixes instantly inside, so coarse graphs make waves too fast. Choose regions small enough that people inside really do mix fast, compared with how fast the epidemic grows.
Module 4 recap. That's Module four: patches linked by travel, networks of people, waves in continuous space, and norms that bound them all. Next, Module five: when the pathogen itself changes. Several strains, immunity, and mutation.
5:42Episode 13 · 4.1Cities linked by travelTravel decides when an epidemic arrives, not how big it gets; arrival follows effective distance, not the map.
5:07Episode 14 · 4.2Networks of peopleOn networks the threshold depends on excess degree: hubs lower it and speed spread, clustering slows it.
4:28Episode 15 · 4.3Epidemics in continuous spaceReaction plus diffusion makes waves with speed 2√(D r); borders, drift and long jumps reshape them.
5:30Episode 16 · 4.4Bounding the spreadAny matrix norm below one proves an outbreak dies out; the spectral radius tells the long run, norms the short run.
Interactive lab
Cities, travel and networks
Change how much people travel between five cities and when a border closes, then compare how often outbreaks take off on three kinds of contact network.
The cities panel solves a metapopulation SIR model as you move the sliders; the network panel builds a 400-person network and runs exact random-event SIR outbreaks on it, in your browser.
Space in two ways
Five cities on a line, linked by travel; then 400 people on a contact network. Both run in your browser.
T is the chance an edge transmits before the infected end recovers. A large outbreak needs T × mean excess degree above 1.
Cutting travel delays the wave in the far cities; it does not change how many get infected in the end.
Solving…
Infected now, city by city
City 1 orange, then amber, green, blue and grey along the line.
Challenges
Each one is checked on your current settings, here or in the network panel below.
- Make the last city peak at least 80 days after the first.
- With travel at 1 in 100 per day, use a closure to push city 5’s peak at least 15 days later.
- With T = 0.30, pick a network where fewer than 10% of runs take off.
Running…
Final sizes
How many runs ended at each share infected (5% bins); green: runs that fizzled.
