EoN Examples

We have collected a number of examples using EoN to generate figures. We start with examples from the book Mathematics of Epidemics on Networks. Then we give a few other examples. If none of these examples helps with the particular problem you are facing, Submit an issue and I’ll try to help.

Reproducing figures from “Mathematics of Epidemics on Networks”

Here are examples to generate (close approximations to) many of the figures in Mathematics of Epidemics on Networks: from Exact to Approximate Models.

Chapter 1


Chapter 2

Top down models

Chapter 3

Bottom up models

Chapter 5

Heterogeneous meanfield

For Chapter 5 figures, these examples use larger populations than the figures in the text.

Figures 5.3, 5.4, and 5.5 demonstrate the ease of the X_from_graph versions of the analytic equations

Chapter 6

Percolation and EBCM

The remainder of these simulations use reduced sizes or numbers of iterations compared to the published figure. This is to save time.

Chapter 7

Model hierarchies

Chapter 9

Non-Markovian processes

For Chapter 9 (nonMarkovian) figures, we have not implemented code that solves the dynamic equations but we do have code that will do the simulations. These are given here.

Additional Examples

Visualizing or animating disease spread

We can visualize snapshots or animations of disease spread in a network.

Non-uniform infectiousness

Perhaps the population is made up of different types of individuals with different infectiousness. This example considers a heterosexual population where one group is more infectious than the other. This example includes a user-defined transmission function and uses the simulation investigation tools to look at the dynamics in each population.

Weighted networks

You may have edges (or nodes) with weights affecting transmission or recovery rates. (for this be aware that the syntax of edge/node attributes is different for networkx 2.x and 1.x).

Non-SIS/SIR processes with Gillespie_Arbitrary

The default Gillespie and Event-driven algorithms assume SIS or SIR dynamics. However, you may want something else, such as SEIR or SIRS or maybe more exotic things. If you are willing to assume that events all happen as Poisson processes (that is, an event happens at a rate), then it’s possible to do this with a Gillespie approach.


Are you trying to do something but can’t figure it out and would like an example?

Submit an issue and I’ll try to help.