EoN.fast_SIS¶
-
EoN.
fast_SIS
(G, tau, gamma, initial_infecteds=None, rho=None, tmin=0, tmax=100, transmission_weight=None, recovery_weight=None, return_full_data=False, sim_kwargs=None)[source]¶ Fast SIS simulations for epidemics on weighted or unweighted networks, allowing edge and node weights to scale the transmission and recovery rates. Assumes exponentially distributed times to recovery and to transmission.
From figure A.5 of Kiss, Miller, & Simon. Please cite the book if using this algorithm.
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 infected is int(round(G.order()*rho))
- tmin number (default 0)
- starting time
- tmax number (default 100)
- stop time
- transmission_weight string (default None)
- the label for a weight given to the edges. transmission rate is G.adj[i][j][transmission_weight]*tau
- recovery_weight string (default None)
- a label for a weight given to the nodes to scale their
recovery rates
gamma_i = G.nodes[i][recovery_weight]*gamma
- 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 each a numpy array
- 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.fast_SIS(G, tau, gamma, tmax = 10, initial_infecteds = range(initial_size)) plt.plot(t, I)