Covid19 network model

Covid19 network model preview image

1 collaborator



"examines the spread of the virus across a network"

Tagged by Stuart Kininmonth over 4 years ago

covid-19, epidemiology 

"examines the spread of the virus across a network"

Tagged by Stuart Kininmonth over 4 years ago

small world 

"examines the spread of the virus across a network"

Tagged by Stuart Kininmonth over 4 years ago

social networks 

"examines the spread of the virus across a network"

Tagged by Stuart Kininmonth over 4 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 819 times • Downloaded 32 times • Run 0 times
Download the 'Covid19 network model' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


This model simulates the expansion of a virus like COVID-19 through a social network. Each 'person' node may be in one of three states: susceptible, infected, or resistant. In the academic literature such a model is sometimes referred to as an SIR model for epidemics.


For each time step (tick), all infected nodes (colored red) will attempt to infect all of its neighbors. The Susceptible neighbors (colored blue) will be infected with a probability given by the VIRUS-SPREAD-CHANCE slider. Resistant nodes (colored gray) cannot be infected. Infected nodes are not immediately aware that they are infected. Only every so often (determined by the VIRUS-CHECK-FREQUENCY slider) do the nodes check whether they are infected by a virus. When the virus has been detected, there is a probability that the virus will be removed (determined by the RECOVERY-CHANCE slider) by some unknown drug. If a node does recover, there is some probability that it will become resistant to this virus in the future (given by the GAIN-RESISTANCE-CHANCE slider). When a node becomes resistant, the links between it and its neighbors are darkened, since they are no longer possible vectors for spreading the virus.


Using the sliders, choose the people via NUMBER-OF-NODES (limited to 500) and the AVERAGE-NODE-DEGREE (average number of links coming out of each node). Note that average means that there will be less and also more links created by chance. The network that is created is based on proximity (Euclidean distance) between nodes. A node is randomly chosen and connected to the nearest node that it is not already connected to. This process is repeated until the network has the correct number of links to give the specified average node degree. The INITIAL-OUTBREAK-SIZE slider determines how many of the nodes will start the simulation infected with the virus. This is an important one to play with.

Then press SETUP to create the network. Press GO to run the model. The model will stop running once the virus has completely died out.

The NETWORK STATUS plot shows the number of nodes in each state (S, I, R) over time.


At the end of the run, after the virus has died out, some nodes are still susceptible, while others have become immune. The interesting part is how the structure of the social network plays a role in the groups of susceptiple people. Vary the social contact with the number of links and see the rapid change.


Set the capacity to become immune to zero (GAIN-RESISTANCE-CHANCE = 0%). Under what conditions will the virus still die out? How long does it take? What conditions are required for the virus to live? If the RECOVERY-CHANCE is bigger than 0, even if the VIRUS-SPREAD-CHANCE is high, do you think that if you could run the model forever, the virus could stay alive?


Try making a model similar to this one, but where the virus has the ability to mutate itself. Such self-modifying viruses are a considerable threat to human health (for example malaria), since traditional methods of virus vaccine may not work against them. In your model, nodes that become immune may be reinfected if the virus has mutated to become significantly different than the variant that originally infected the node.


Links are used for modeling the network. The layout-spring primitive is used to position the nodes and links such that the structure of the network is visually clear. Though it is not used in this model, there exists a network extension for NetLogo that you can download at:


Virus, Disease, Preferential Attachment, Diffusion on a Directed Network


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below. For the model itself: Stuart Kininmonth (2020) COVID-19 spread on a social network.Netlogo.

Stonedahl, F. and Wilensky, U. (2008). NetLogo Virus on a Network model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Please cite the NetLogo software as: Wilensky, U. (1999). NetLogo. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

extensions [ vid bitmap ]
  infected?           ;; if true, the turtle is infectious
  resistant?          ;; if true, the turtle can't be infected
  virus-check-timer   ;; number of ticks since this turtle's last virus-check

to setup
  ask n-of initial-outbreak-size turtles
    [ become-infected ]
  ask links [ set color white ]
 ; ca
  ;crt 10

to setup-nodes
  set-default-shape turtles "circle"
  create-turtles number-of-nodes
    ; for visual reasons, we don't put any nodes *too* close to the edges
    setxy (random-xcor * 0.95) (random-ycor * 0.95)
    set virus-check-timer random virus-check-frequency

to setup-spatially-clustered-network
  let num-links (average-node-degree * number-of-nodes) / 2
  while [count links < num-links ]
    ask one-of turtles
      let choice (min-one-of (other turtles with [not link-neighbor? myself])
                   [distance myself])
      if choice != nobody [ create-link-with choice ]
  ; make the network look a little prettier
  repeat 10
    layout-spring turtles links 0.3 (world-width / (sqrt number-of-nodes)) 1

to go
  if all? turtles [not infected?]
    [ vid:save-recording "filme.mp4"
    print vid:recorder-status
  if vid:recorder-status = "inactive" [
  ask turtles
     set virus-check-timer virus-check-timer + 1
     if virus-check-timer >= virus-check-frequency
       [ set virus-check-timer 0 ]

to become-infected  ;; turtle procedure
  set infected? true
  set resistant? false
  set color red

to become-susceptible  ;; turtle procedure
  set infected? false
  set resistant? false
  set color blue

to become-resistant  ;; turtle procedure
  set infected? false
  set resistant? true
  set color gray
  ask my-links [ set color gray - 2 ]

to spread-virus
  ask turtles with [infected?]
    [ ask link-neighbors with [not resistant?]
        [ if random-float 100 < virus-spread-chance
            [ become-infected ] ] ]

to do-virus-checks
  ask turtles with [infected? and virus-check-timer = 0]
    if random 100 < recovery-chance
      ifelse random 100 < gain-resistance-chance
        [ become-resistant ]
        [ become-susceptible ]

; Stuart Kininmonth 2020
; Adapted from 2008 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created over 4 years ago by Stuart Kininmonth.

Attached files

File Type Description Last updated
Covid19 network model.png preview Preview for 'Covid19 network model' over 4 years ago, by Stuart Kininmonth Download

This model does not have any ancestors.

This model does not have any descendants.