Forest Fires, Epidemics and Models

What can forest fires tell us about epidemic modelling?

Anthony B. Masters
3 min readMay 30, 2020


Using code, we can simulate forest fires. This is often an introductory lesson in programming languages.

This simple model of a forest fire can inform us about the epidemic spread of diseases.

Setting up the lattice

In R, there is the igraphs package. This package can make lattice graphs.

The basic lattice sets up a grid where each vertex connects to its four adjacent neighbours. Mathematicians call that central vertex and those four neighbours the von Neumann neighbourhood.

test_lattice <- make_lattice(length = 5, dim = 2, nei = 1)
test_lattice %>% plot(layout = layout_on_grid)
The corner vertices only have two von Neumann neighbours. (Image: R)

For forest fires, diagonal connections to each vertex are important too.

There is no setting in the make_lattice function for these extra connections. We need to create the extra edges, and add them.

extra_edges_df <- tibble(x = as.numeric(1:20,
w = case_when(x %% forest_length == 1 ~ NA_real_,
TRUE ~ x + forest_length - 1),
z = case_when(x %% forest_length == 0 ~ NA_real_,
TRUE ~ x + forest_length + 1)) %>%
pivot_longer(cols = 2:3,
names_to = "column",
values_to = "y",
values_drop_na = TRUE) %>%
select("x", "y")

The add_edges function takes matrices in a counter-intuitive way.

extra_edges_v <- cbind(extra_edges_df$x, extra_edges_df$y)
%>% t() %>% c()

We can then add these edges on.

test_lattice_added <- test_lattice %>% add_edges(edges = extra_edges_v)
test_lattice_added %>% plot(layout = layout_on_grid)
Behold. (Image: R)

Mathematicians call a vertex and its eight neighbours the Moore neighbourhood.

We can then set up fixed or probabilistic rules for the three different states:

  • Alive: the tree is green, and could be set on fire by neighbouring trees.
  • On fire: the tree is on…



Anthony B. Masters

This blog looks at the use of statistics in Britain and beyond. It is written by RSS Statistical Ambassador and Chartered Statistician @anthonybmasters.