Fast code for SIR on temporal networks
Clone or download
Latest commit 230bc4b Jul 29, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Create LICENSE Jul 27, 2018
Makefile adapt for new RNG Jul 27, 2018 Update Jul 29, 2018
heap.c Add files via upload Jul 23, 2018
misc.c simplified bcoz the new RNG Jul 27, 2018 Add files via upload Jul 23, 2018
pcg_rnd.c Update pcg_rnd.c Jul 29, 2018
quick.c Add files via upload Jul 23, 2018
tsir.c fixed typo Jul 28, 2018
tsir.h adapted for new RNG Jul 28, 2018

Crazy fast code for the SIR model on temporal networks

It follows the model descriptions in this blog post: The algorithm is discussed here:

To get it running you need:

  1. Make a directory o (for complier object files)
  2. Compile it by make and GCC* (it has some generic optimization flags now). If you want to omit the timing, compile it without the -DTIME flag.
  3. Run it like

./tsir nwk/office.csv 0.2 5

The first argument is the file containing the network. The input format is a blank-space separated contact list (vertex-id 1, vertex-id 2, time) 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. It also assumes the contact list is sorted in time and starts with time 0. To check if your file format is correct, there is a Python program You can run it as python filename If something is stange with your file, it will let you know. The example network in the nwk folder comes from:

The third argument is the per-contact infection rate. The fourth is the recovery rate in time units of the duration of the data. If you have the recovery rate in days, you need to divide it by the duration of the data to get the value that goes here.

For more comments, see the files. It should a be relatively easy read for a C coder.

* Clang does not handle the bit-rotation of the RNG efficiently (according to the RNG, for Clang one might want to use another RNG).