Noisy threshold-based contagion in a small world
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is a contagion model on a Watts-Strogatz small world topology. Nodes are either susceptible (S) or infected (I). This version allows studying how network structure affects "simple" and "complex" (threshold-based) contagions.
NETWORK STRUCTURE
This network model is an adaptation of a model proposed by Duncan Watts and Steve Strogatz (1998). It begins with a network where each person (or "node") is connected to his or her two neighbors on either side... The REWIRING-PROBABILITY slider determines the probability that an edge will get rewired" (so that one of its endpoints goes to a random node instead of a neighbor). Clicking the setup button will produce different network configurations, all with the same rewiring probability.
The NUM-NODES slider controls the size of the network. Choose a size and press SETUP.
Changing the REWIRING-PROBABILITY slider changes the fraction of nodes rewired. Press SETUP A NEW NEWTORK to generate the new network. SETUP will also infect one node.
You can also experiment with complex contagion: a node will become infected if at least two of its neighbors are.
CONTAGION
This implements two models of contagion.
Simple contagion
The first, "simple contagion" is a SI (susceptible-infected) model in which, in each time step, there is a chance each infected node infects each susceptible neighbor.
The PROB-INFECTION slider determines the probability that an infected individual will infect a susceptible contact at every time step, i.e. the infectiousness of the spreading agent.
To re-infect two adjacent individuals while keeping the same topology - press REINFECT-TWO.
Now to allow the disease to spread, you can advance one time step at a time (each infected node will infect each of its neighbors with probability prob-infection) with the "spread once" button. To let the disease run its full course, you can click the "spread complete" button.
You can also slow down the process using the slower-faster slider at the top of the model interface.
Complex contagion (threshold-based contagion)
The second contagion model is a "complex contagion" in which there is a threshold for adoption: nodes adopt with some probability when they have at least some number of neighbors who adopt. Here that threshold is 2 adopter neighbors.
PROB-SPREAD-TWO is the probability of adopting in each time step if at least 2 neighbors have adopted.
A deterministic threshold may not be realistic, so we can also set PROB-SPREAD-ONE, which is the probability of adopting in each time step if only one neighbor has adopted.
THINGS TO TRY
Try plotting the values for different rewiring probabilities and observe how long the infection survives in the network, and how far it spreads. Also consider the differing effect of rewiring on simple and complex contagion.
RELATED MODELS
See other models in the Networks section of the Models Library, such as Giant Component and Preferential Attachment. Also check out Lada's other NetLogo models:
http://www.ladamic.com/netlearn
CREDITS AND REFERENCES
This model was adapted from: Wilensky, U. (2005). NetLogo Small Worlds model. http://ccl.northwestern.edu/netlogo/models/SmallWorlds. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
It was written by Lada Adamic and Eytan Bakshy in 2007 and 2008, revised 2012.
This version includes changes by Dean Eckles in 2018 and 2021 to add complex contagion and uses some prior modifications by Paul Smaldino.
Comments and Questions
globals [ num-infected infected-size ] turtles-own [ infected? ;; true if agent has been infected ] ;;;;;;;;;;;;;;;;;;;;;;; ;;; Main Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;; to complex-spread if all? turtles [infected?] [stop] ask turtles with [ infected? = true ] [ ;; infect neighbors ask link-neighbors [ if (( random-float 1 <= prob-spread-two ) and ((count link-neighbors with [infected? = true] > 1) or (count link-neighbors with [infected? = true] = 1 and random-float 1 <= prob-spread-one))) ;; infect with probability p [ if not infected? ;; agents can be infected only once [ set infected? true show-turtle set color yellow set size infected-size ;; color the link with the node doing the infection ask link-with myself [set color yellow show-link] ;; increment the total number of infected agents ] ] ] ] do-plotting set num-infected count turtles with [infected? = true] tick end to spread ;; or if every agent has already been infected if all? turtles [infected?] [stop] ask turtles with [ infected? = true ] [ ;; infect neighbors ask link-neighbors [ if ( random-float 1 <= prob-infection ) ;; infect with probability p [ if not infected? ;; agents can be infected only once [ set infected? true show-turtle set color yellow set size infected-size ;; color the link with the node doing the infection ask link-with myself [set color yellow show-link] ;; increment the total number of infected agents ] ] ] ] do-plotting set num-infected count turtles with [infected? = true] tick end ;;layout all nodes and links to do-layout repeat 5 [layout-spring turtles links 0.2 4 0.9] display end ;;;;;;;;;;;;;;;;;;;;;;;; ;;; Setup Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;; to generate-topology ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) clear-all set infected-size 4 set-default-shape turtles "outlined circle" ;; setup small world topology create-turtles num-nodes create-lattice rewire-network setup reset-ticks end to reinfect-two set infected-size 4 ask turtles [reset-node] ask links [set color gray + 1.5] ;; infect a single agent ask one-of turtles [ set infected? true set color yellow set size infected-size ask one-of link-neighbors [ set infected? true set color yellow set size infected-size ] ] set num-infected 1 ;; Layout turtles: layout-circle (sort turtles) max-pxcor - 8 ;; space out turtles to see clustering ask turtles [ facexy 0 0 if who mod 2 = 0 [fd 4] ] display end to setup set infected-size 4 ask turtles [reset-node] ask links [set color gray + 1.5] ;; infect a single agent ask one-of turtles [ set infected? true set color yellow set size infected-size ] set num-infected 1 reinfect-two ;; Layout turtles: layout-circle (sort turtles) max-pxcor - 8 ;; space out turtles to see clustering ask turtles [ facexy 0 0 if who mod 2 = 0 [fd 4] ] display end to reset-node set color gray + 1.5 set size 3 set infected? false end ;; WARNING: the simplified rewiring algorithm does not certain checks (ie disconnected graph) ;; for large networksthis shouldn't be too much of an issue. to rewire-network ask links [ ;; whether to rewire it or not? if (random-float 1) < rewiring-probability [ ask end1 [ create-link-with one-of other turtles with [not link-neighbor? myself ] [set color gray + 1.5] ] die ] ] end ;; creates a new lattice to create-lattice ;; iterate over the nodes let n 0 while [n < count turtles] [ ;; make links with the next two neighbors ;; this makes a lattice with average degree of 4 make-link-between turtle n turtle ((n + 1) mod count turtles) make-link-between turtle n turtle ((n + 2) mod count turtles) set n n + 1 ] end ;; connects the two nodes to make-link-between [node1 node2] ask node1 [ create-link-with node2 [ set color gray + 1.5] ] end to-report pct-infected report 100 * (num-infected ) / (count turtles) end ;;;;;;;;;;;;;;;; ;;; Plotting ;;; ;;;;;;;;;;;;;;;; to do-plotting ;; plot the number of infected individuals at each step set-current-plot "% infected" set-current-plot-pen "inf" let percent-inf 100 * (num-infected ) / (count turtles) plotxy ticks percent-inf end
There are 9 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Noisy threshold-based contagion in a small world.png | preview | Preview for 'Noisy threshold-based contagion in a small world' | over 4 years ago, by Dean Eckles | Download |
This model does not have any ancestors.
This model does not have any descendants.