EoN.SIS_pair_based

EoN.SIS_pair_based(G, tau, gamma, rho=None, nodelist=None, Y0=None, XY0=None, XX0=None, tmin=0, tmax=100, tcount=1001, transmission_weight=None, recovery_weight=None, return_full_data=False)[source]

Encodes System (3.26) of Kiss, Miller, & Simon. Please cite the book if using this algorithm.

WARNING: this does NOT solve the pairwise equations. Look at SIS_homogeneous_pairwise and SIS_heterogeneous_pairwise for that.

This system solves equations for an SIS disease model spreading on a given graph.

It captures the dependence with pairs, but not triples.

It does not include corrections for triangles (or any other cycles).

The corrections for triangles are provided in the text, but not implemented here.

There are some inefficiencies in the implementation:

we track all pairs, rather than just those pairs in edges, but this is unlikely to significantly affect the calculation time.

This makes it much easier to vectorize things.

We track pairs in both directions: e.g., XX[1,2] and XX[2,1].

Arguments:

G networkx Graph

tau positive float
transmission rate of disease
gamma number
global recovery rate
rho (float between 0 and 1, default None)
proportion assumed initially infected. If None, then Y0 is used if Y0 is also None, then rho = 1./N
nodelist list
list of nodes in G in some prescribed order (just since there is no guarantee that G returns nodes in the same order if things change a bit.)
Y0 numpy array
the array of initial infection probabilities for each node in the same order as in nodelist
XY0 2D numpy array (default None)
(each dimension has length number of nodes of G) XY0[i,j] is probability node i is susceptible and j is infected. if None, then assumes that infections are introduced randomly according to Y0.
XX0 2D numpy array (default None)
(each dimension has length number of nodes of G) XX0[i,j] is probability nodes i and j are susceptible. if None, then assumes that infections are introduced randomly according to Y0.
tmin number (default 0)
minimum report time
tmax number (default 100)
maximum report time
tcount integer (default 1001)
number of reports
transmission_weight string
the label for a weight given to the edges. G.edge[i][j][transmission_weight] = g_{ij}
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)
if True:
returns times, S, I, R, Xs, Ys, Zs, XY, XX
if False:
returns times, S, I, R
Returns:
if return_full_data is True:
returns times, S, I, Xs, Ys, XY, XX
if False:
returns times, S, I
SAMPLE USE:
import networkx as nx
import EoN

G = nx.fast_gnp_random_graph(1000,0.004)
nodelist = G.nodes()
Y0 = np.array([1 if node<10 else 0 for node in nodelist]) #infect first 10
t, S, I = EoN.SIS_pair_based(G, 2, 0.5, nodelist, Y0, tmax = 4, tcount = 101)
plt.plot(t,I)