EoN.Gillespie_SIS

EoN.Gillespie_SIS(G, tau, gamma, initial_infecteds=None, rho=None, tmin=0, tmax=100, recovery_weight=None, transmission_weight=None, *, rng=None, return_full_data=False, sim_kwargs=None)[source]

Performs SIS simulations for epidemics on networks with or without weighted edges.

It assumes that the edges have a weight associated with them and that the transmission rate for an edge is tau*weight[edge]

Based on an algorithm by Petter Holme. It requires a weighted choice of edges and this will be done by tracking the maximum edge weight and then using repeated rejection samples until a successful selection.

See Also:

fast_SIS which has the same inputs but uses a faster method (esp for weighted graphs).

Arguments:

G (NetworkX Graph)

The underlying network

tau (positive float)

transmission rate per edge

gamma number

recovery rate per node

initial_infecteds node or iterable of nodes

if a single node, then this node is initially infected

if an iterable, then whole set is initially infected

if None, then choose randomly based on rho.

If rho is also None, a random single node is chosen.

If both initial_infecteds and rho are assigned, then there is an error.

rho number

initial fraction infected. number is int(round(G.order()*rho))

tmin number (default 0)

starting time

tmax number

stop time

recovery_weight string (default None)

the string used to define the node attribute for the weight. Assumes that the recovery rate is gamma*G.nodes[u][recovery_weight]. If None, then just uses gamma without scaling.

transmission_weight string (default None)

the string used to define the edge attribute for the weight. Assumes that the transmission rate from u to v is tau*G.adj[u][v][transmission_weight]

rng random number generator

If None, will be set to np.random.default_rng()

return_full_data boolean (default False)

Tells whether a Simulation_Investigation object should be returned.

sim_kwargs keyword arguments

Any keyword arguments to be sent to the Simulation_Investigation object Only relevant if return_full_data=True

Returns:

times, S, I numpy arrays

giving times and number in each status for corresponding time

or if return_full_data==True

full_data Simulation_Investigation object

from this we can extract the status history of all nodes We can also plot the network at given times and even create animations using class methods.

SAMPLE USE:

import networkx as nx
import EoN
import matplotlib.pyplot as plt

G = nx.configuration_model([1,5,10]*100000)
initial_size = 10000
gamma = 1.
tau = 0.2
t, S, I = EoN.Gillespie_SIS(G, tau, gamma, tmax = 20,
                            initial_infecteds = range(initial_size))

plt.plot(t, I)