예제 #1
0
t, S, I, R = EoN.SIR_homogeneous_pairwise_from_graph(G,
                                                     tau,
                                                     gamma,
                                                     rho=rho,
                                                     tmax=tmax)
plt.plot(t, I, '-.', label='Homogeneous pairwise', linewidth=5)
#meanfield models will generally overestimate SIR growth because they
#treat partnerships as constantly changing.
t, S, I, R = EoN.SIR_heterogeneous_meanfield_from_graph(G,
                                                        tau,
                                                        gamma,
                                                        rho=rho,
                                                        tmax=tmax)
plt.plot(t, I, ':', label='Heterogeneous meanfield', linewidth=5)
#The EBCM model does not account for degree correlations or clustering
t, S, I, R = EoN.EBCM_from_graph(G, tau, gamma, rho=rho, tmax=tmax)
plt.plot(t, I, '--', label='EBCM approximation', linewidth=5)
#the preferential mixing model captures degree correlations.
t, S, I, R = EoN.EBCM_pref_mix_from_graph(G, tau, gamma, rho=rho, tmax=tmax)
plt.plot(t, I, label='Pref mix EBCM', linewidth=5, dashes=[4, 2, 1, 2, 1, 2])
plt.xlabel('$t$')
plt.ylabel('Number infected')
plt.legend()
# plt.savefig('SIR_BA_model_vs_sim.png')

# The preferential mixing version of the EBCM approach provides the best approximation to the (gray) simulated epidemics.
#
# We now move on to SIS epidemics:
#

# ## SIS
    G, tau, gamma, initial_infecteds=initial_infecteds, tmax=10, tcount=51)
plt.plot(t, S, color=colors[2], dashes=[6, 6], label='effective degree')
plt.plot(t, I, color=colors[2], dashes=[6, 6])
plt.plot(t, R, color=colors[2], dashes=[6, 6])

t, S, I, R = EoN.SIR_heterogeneous_pairwise_from_graph(
    G, tau, gamma, initial_infecteds=initial_infecteds, tmax=10, tcount=51)
plt.plot(t,
         S,
         color=colors[3],
         dashes=[3, 2, 1, 2],
         linewidth=3,
         label='pairwise')
plt.plot(t, I, color=colors[3], dashes=[3, 2, 1, 2], linewidth=3)
plt.plot(t, R, color=colors[3], dashes=[3, 2, 1, 2],
         linewidth=3)  #, dashes = [6,3,2,3]

t, S, I, R = EoN.EBCM_from_graph(G,
                                 tau,
                                 gamma,
                                 initial_infecteds=initial_infecteds,
                                 tmax=10,
                                 tcount=51)
plt.plot(t, S, ':', color=colors[4], label='EBCM')
plt.plot(t, I, ':', color=colors[4])
plt.plot(t, R, ':', color=colors[4])

plt.axis(xmax=10, xmin=0)
plt.xlabel('$t$')
plt.legend(loc='center right')
plt.savefig('fig7p4.png')