Epidemic - socrateslab/zh GitHub Wiki

Pastor-Satorras, R. & Vespignani, A. Epidemic spreading in scale-free networks.Phys. Rev. Lett. 86, 3200 (2001).[1]

Tizzoni M, Sun K, Benusiglio D, et al. The Scaling of Human Contacts and Epidemic Processes in Metapopulation Networks[J]. Scientific reports, 2015, 5.[2]

import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
%pylab inline 

def SIS_net(G,p,mu,status):
    # we make the process syncronous
    # at each time step all infected indivuals can infect their peers
    # status is a vector that takes two values for each node
    # 0 -> S
    # 1 -> I
    temp_inf=set()
    temp_rec=set()
    for i in G.nodes():
        # if the node is infected
        if status[i]==1:
            # we go through her neighbors and we try to infect the S
            for j in G.neighbors(i):
                if status[j]==0 and uniform(0,1)<p:
                    temp_inf.add(j) # this node will be infected next
                            
            # recovery process
            if uniform(0,1)<mu:
                temp_rec.add(i)
                
    # update the status
    for i in temp_inf:
        status[i]=1  
    for i in temp_rec:
        status[i]=0
        
  1. we need to select the initial infected population
  2. let us create a function to select a fraction p of nodes
  3. as initial seeds
def set_seeds(status,p): # we get the number of infected given a fraction p n_of_infected=int(p*status.size) # we get the list of nodes and shuffle it list_nodes=[] for i in range(status.size): list_nodes.append(i) shuffle(list_nodes) # the first n_of_infected will be the seeds for i in range(n_of_infected): status[list_nodes[i]]=1 def infecting(G, p): N=G.number_of_nodes() status=np.zeros(N,int) # for each node i, status[i]=0 indicates that the node is susceptible # for each node i, status[i]=1 indicates that the node is infected # let us set the seed set_seeds(status,0.1) stop=50 mu=0.5 it=np.zeros(stop,float) for t in range(stop): SIS_net(G,p,mu,status) # number of infected nodes # the sum is the number of infected! inf=float(status.sum()) it[t]=inf/N return it plot_num = 5 cmap = cm.get_cmap('Accent_r', plot_num) def plotDegreeDistribution(G): plt.plot(nx.degree_histogram(G) , 'ro', markersize = 8) #čŋ”å›žå›žä¸­æ‰€æœ‰čŠ‚į‚šįš„åēĻ分布åēåˆ— plt.legend(['Degree']) plt.xlabel('Degree') plt.ylabel('Number of nodes') plt.title('Degree Distribution') plt.xscale('log') plt.yscale('log') plt.show() G = nx.barabasi_albert_graph(500, 1, seed=None)
  1. plotDegreeDistribution(G)
for k, p in enumerate(np.linspace(0.8,0.9, plot_num)): it = infecting(G, p) plt.plot(it,c= cmap(k),linewidth=4,alpha=0.5, label = 'P = '+str(np.round(p, 2)) ) plt.xlabel('t') plt.ylabel('i(t)') lg = plt.legend(loc = 0 )#bbox_to_anchor=(1.3, 0.965)) lg.draw_frame(False) plt.show()

400px

:File:srep15111-s1.pdf

The Internet has a very complex connectivity recently modeled by the class of scale-free networks. This feature, which appears to be very efficient for a communications network, favors at the same time the spreading of computer viruses. We analyze real data from computer virus infections and find the average lifetime and persistence of viral strains on the Internet. We define a dynamical model for the spreading of infections on scale-free networks, finding the absence of an epidemic threshold and its associated critical behavior. This new epidemiological framework rationalizes data of computer viruses and could help in the understanding of other spreading phenomena on communication and social networks.

å‚č€ƒæ–‡įŒŽ

- Pastor-Satorras, R. & Vespignani, A. Epidemic spreading in scale-free networks. Phys. Rev. Lett. 86, 3200 (2001). pdf - Tizzoni M, Sun K, Benusiglio D, et al. The Scaling of Human Contacts and Epidemic Processes in Metapopulation Networks[J]. Scientific reports, 2015, 5. pdf

âš ī¸ **GitHub.com Fallback** âš ī¸