# EoN.get_infected_nodes¶

EoN.get_infected_nodes(G, tau, gamma, initial_infecteds=None, initial_recovereds=None)[source]

Finds all eventually infected nodes in an SIR simulation, through a percolation approach

From figure 6.15 of Kiss, Miller, & Simon. Please cite the book if using this algorithm

Assumes that the intial infecteds are as given and transmission occurs with rate tau and recovery with rate gamma.

Note that the output of this algorithm is stochastic.

This code has similar run-time whether an epidemic occurs or not. There are much faster ways to implement an algorithm giving the same output, for example by actually running one of the epidemic simulation tools.

why are you using this command? If it’s to better understand the relationship between percolation and SIR epidemics, that’s fine. But this command IS NOT an efficient way to calculate anything. Don’t do it like this. Use one of the other algorithms. Try fast_SIR, for example.

G networkx Graph
The network the disease will transmit through.
tau positive float
transmission rate
gamma positive float
recovery rate
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 a randomly chosen node is initially infected.
initial_recovereds node or iterable of nodes
if a single node, then this node is initially recovered if an iterable, then whole set is initially recovered
infected_nodes set
the set of nodes infected eventually in a simulation.
import networkx as nx
import EoN

G = nx.fast_gnp_random_graph(1000,0.002)

finalR = EoN.get_infected_nodes(G, 2, 1, initial_infecteds=[0, 5])

#finds the nodes infected if 0 and 5 are the initial nodes infected
#and tau=2, gamma=1