The applet requires Java 1.4.1 or higher.

powered by NetLogo

view/download model file: virus.nlogo


This is a testbed for exploring using immunization to slow the spread of a virus on a network. It also provides a dynamic graph layout model using springs and repulsion forces to create a pleasing layout.


We currently provide two graph types: random and power-law. The random graph simply connects random pairs of nodes together until the graph is fully connected and the number of edges is equal to or greater than the desired number.

There are several parameters and actions for the spread of the virus. First, one creates a graph using "setup". Then you immunize some percentage of the population (by default, 10%). Then, you infect some percentage of the population (by default, 3%). Then, you "go" and the infection spreads. Various parameters can be modified.

The graph layout system uses two parameters (number-of-nodes and edge-ratio) to create the graph. For example, if the number of nodes is 10 and the edge ratio is 1.2, then the target graph would have 10 nodes and 12 edges.

Three parameters are used to adjust the layout. The spring-force is how strongly the spring pushes/pulls the nodes. The spring-length is the 0-force length of the spring. Greater lengths attract, lesser repel. The total force is the spring-force times the amount the spring differs from its spring-length. Finally, there is a general repulsion between all nodes, specified by the mutual-repulsion parameter. It uses an inverse-square calculation rather than the spring's linear one.


Click on setup to initialize the graph. This can be either a random graph, or a power-law graph. The "set-size" button allows you to see nodes with a visual representation of their degree (number of link-neighbors). After setting up the network, you can "immunize" some percentage of the nodes. This can be via one of three mechanisms: top n% (by degree) ("only-top" on), "friends" (n% at random are asked to identify a friend, at random . . . those friends are immunized) ("only-top" off, "friends" on), "random" (n% at random are immunized) ("only-top" off and "friends" off). After immunization, you can infect some percentage of the agents (at random). Then, "go" (or "step") propagates the virus through the network.

For graph layout, press the "layout" button. While the model is running, you can change the three spring/repulsion parameters. You also can grab a node with the mouse and move it around to help untangle the graph.


The power-law graph uses the Barabási method (Google for his group's papers) which creates fairly "bush-y" power-law graphs. His work helped us understand why web and internet graphs are often power-law by noting that these nets grow 1) progressively from small networks, and 2) link probabilistically to nodes according to "popularity" .. i.e. by number of links.