For using the igraph C library
igraph_error_t igraph_sir(const igraph_t *graph, igraph_real_t beta, igraph_real_t gamma, igraph_integer_t no_sim, igraph_vector_ptr_t *result);
The SIR model is a simple model from epidemiology. The individuals of the population might be in three states: susceptible, infected and recovered. Recovered people are assumed to be immune to the disease. Susceptibles become infected with a rate that depends on their number of infected neighbors. Infected people become recovered with a constant rate. See these parameters below.
This function runs multiple simulations, all starting with a single uniformly randomly chosen infected individual. A simulation is stopped when no infected individuals are left.
Arguments:
|
The graph to perform the model on. For directed graphs edge directions are ignored and a warning is given. |
|
The rate of infection of an individual that is susceptible and has a single infected neighbor. The infection rate of a susceptible individual with n infected neighbors is n times beta. Formally this is the rate parameter of an exponential distribution. |
|
The rate of recovery of an infected individual. Formally, this is the rate parameter of an exponential distribution. |
|
The number of simulation runs to perform. |
|
The result of the simulation is stored here,
in a list of |
Returns:
Error code. |
Time complexity: O(no_sim * (|V| + |E| log(|V|))).
typedef struct igraph_sir_t { igraph_vector_t times; igraph_vector_int_t no_s, no_i, no_r; } igraph_sir_t;
Data structure to store the results of one simulation of the SIR (susceptible-infected-recovered) model on a graph. It has the following members. They are all (real or integer) vectors, and they are of the same length.
Values:
|
A vector, the times of the events are stored here. |
|
An integer vector, the number of susceptibles in each time step is stored here. |
|
An integer vector, the number of infected individuals at each time step, is stored here. |
|
An integer vector, the number of recovered individuals is stored here at each time step. |
void igraph_sir_destroy(igraph_sir_t *sir);
Arguments:
|
The |
← Chapter 9. Graph generators | Chapter 11. Vertex and edge selectors and sequences, iterators → |