Beispiel #1
0
times2, S2, I2, R2 = EoN.fast_SIR(G,
                                  tau1,
                                  gamma,
                                  initial_infecteds=infected,
                                  initial_recovereds=recovered,
                                  tmin=t1,
                                  tmax=tmax)

plt.plot(times0, I0, label='fast_SIR')
plt.plot(
    times1, I1
)  #the first two have the same parameters, so the transition should be as if it were a single simulation
plt.plot(times2,
         I2)  #the infectiousness reduced, so a sharp change should be visible

times0, S0, I0, R0, infection_time, recovery_time = EoN.Gillespie_SIR(
    G, tau0, gamma, rho=rho, tmax=t0, return_full_data=True)

infected, recovered = get_affected_nodes_at_end(infection_time, recovery_time)

times1, S1, I1, R1, infection_time, recovery_time = EoN.Gillespie_SIR(
    G,
    tau0,
    gamma,
    initial_infecteds=infected,
    initial_recovereds=recovered,
    tmin=t0,
    tmax=t1,
    return_full_data=True)

infected, recovered = get_affected_nodes_at_end(infection_time, recovery_time)
Beispiel #2
0
# writing a for loop to get simulations (mean and sd stored) for each graph in our list

nodes = [1000, 900, 800, 700, 600, 500, 400, 300, 200,
         100]  # for plot-divide by respective population

# 100 simulations for each graph
outbreak_list_random = []
for j, n in zip(range(len(immunised_graph_list_random)),
                nodes):  # for all percentage brackets
    mean_outbreak_list = []
    for g in immunised_graph_list_random[
            j]:  # for all graphs in one percentage bracket
        inner_outbreaks = []
        while len(inner_outbreaks) < 2000:  # 2000 simulations for each graph
            sim = eon.Gillespie_SIR(g, 0.95, 1)
            inner_outbreaks.append((sim[1][0] - sim[1][-1]) /
                                   n)  # S(T) - S(0) (Outbreak Size definition)
        mean_outbreak_list.append(inner_outbreaks)
    outbreak_list_random.append(mean_outbreak_list)

# (1) FOR DEGREE CENTRALITY - just change the first line in the inner loop for others

final_node_immunise_list = []
for j in range(len(graph_list2)):  # for all percentage brackets
    inner_immunise_list = []
    for i in range(len(
            graph_list2[j])):  # for all graphs in one percentage bracket
        dc = nx.degree_centrality(graph_list2[j][i])
        dc = pd.DataFrame([dc.keys(), dc.values()]).T
        dc.columns = ['node', 'centrality value']