Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Fast SIR on networks

Pretty quick code for regular (continuous time, Markovian) SIR on simple graphs. I chatty intro to it here:

To get it running you need:

  1. Make dictionary o (for complier object files)
  2. Compile it by make (it has some generic optimization flags now)
  3. Run it like

./sir nwk/iceland.lnk 1.5 11958364283164656333

The first argument is the file containing the network. The input format is an edge list assuming the vertex-id numbers are between 0 and N - 1. The program sets N as one plus the largest index observed, so if your network has isolates make sure at least the largest id has degree > 0. The example network comes from: Haraldsdottir S, Gupta S, Anderson RM, Preliminary studies of sexual networks in a male homosexual community in Iceland, J Acquir Immune Defic Syndr. 1992;5(4):374-81.

The second argument is the per-link infection rate. I assume the recovery rate is one (if some other rate is needed, you just have to divide the infection rate by the recovery rate and divide the output extinction time by the recovery rate).

The third argument is the seed for the RNG = a 64-bit unsigned decimal integer. Ideally this number should be as entropic as possible, i.e. itself generated by a random number generator. In practice sir should be run with a wrapper. A very simple (Python) such is supplied that could be run on the command line as:

python3 nwk/iceland.lnk

It generates: the average outbreak size, error in ditto, the average extinction time, error in ditto . . for seven exponentially increasing beta values.

For more comments, see the files.


Pretty quick code for regular (continuous time, Markovian) SIR on networks



No releases published


No packages published