EoN.estimate_nonMarkov_SIR_prob_size_with_timing

EoN.estimate_nonMarkov_SIR_prob_size_with_timing(G, trans_time_fxn, rec_time_fxn, trans_time_args=(), rec_time_args=())[source]

estimates probability and size for user-input transmission and recovery time functions.

Arguments:

G Networkx Graph

the input graph

trans_time_fxn function

trans_time_fxn(u, v, *trans_time_args) returns the delay from u’s infection to transmission to v.

rec_time_fxn function

rec_time_fxn(u, *rec_time_args) returns the delay from u’s infection to its recovery.

trans_time_args tuple

any additional arguments required by trans_time_fxn. For example weights of nodes.

rec_time_args tuple

any additional arguments required by rec_time_fxn

No random number generator seed is included. If the input functions use them, and a fixed seed is desired, this should be included in trans_time_args and rec_time_args.

Returns:

PE, AR numbers (between 0 and 1)

Estimates of epidemic probability and attack rate found by finding largest strongly connected component and finding in/out components.

SAMPLE USE:

#mimicking the standard version with transmission rate tau
#and recovery rate gamma
#equivalent to
#PE, AR = EoN.estimate_SIR_prob_size(G, tau, gamma)

import networkx as nx
import EoN
import random
from collections import defaultdict

G=nx.fast_gnp_random_graph(1000,0.002)

tau = 2

gamma = 1

def trans_time_fxn(u,v, tau):

    return rng.exponential(1/tau)

def rec_time_fxn(u, gamma):

    return rng.exponential(1/gamma)

PE, AR = EoN.estimate_nonMarkov_SIR_prob_size(G,
                                            trans_time_fxn=trans_time_fxn,
                                            rec_time_fxn = rec_time_fxn,
                                            trans_time_args = (tau,),
                                            rec_time_args = (gamma,)
                                            )