15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

334 CHAPTER 16. DYNAMICAL NETWORKS I: MODELING(p i )(p i )Infection from o<strong>the</strong>rinfected nodesStaying infected(1 – p r )1 Susceptible2InfectedRecovery (p r )Figure 16.3: Schematic illustration <strong>of</strong> <strong>the</strong> state-transition rule <strong>of</strong> <strong>the</strong> SIS model.Regarding <strong>the</strong> updating scheme, I think you probably liked <strong>the</strong> simplicity <strong>of</strong> <strong>the</strong> asynchronousupdating we used for <strong>the</strong> voter model, so let’s adopt it for this SIS model <strong>to</strong>o.We will first choose a node r<strong>and</strong>omly, <strong>and</strong> if it is susceptible, <strong>the</strong>n we will r<strong>and</strong>omly chooseone <strong>of</strong> its neighbors; this is similar <strong>to</strong> <strong>the</strong> original “pull” version <strong>of</strong> <strong>the</strong> voter model. All youneed is <strong>to</strong> revise just <strong>the</strong> updating function as follows:Code 16.6: SIS-model.pyp_i = 0.5 # infection probabilityp_r = 0.5 # recovery probabilitydef update():global ga = rd.choice(g.nodes())if g.node[a][’state’] == 0: # if susceptibleb = rd.choice(g.neighbors(a))if g.node[b][’state’] == 1: # if neighbor b is infectedg.node[a][’state’] = 1 if r<strong>and</strong>om() < p_i else 0else: # if infected

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!