NetLogo Models Library:
This model is from Chapter Five of the book "Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo", by Uri Wilensky & William Rand.
This model is in the IABM Textbook folder of the NetLogo Models Library. The model, as well as any updates to the model, can also be found on the textbook website: http://www.intro-to-abm.com/.
The theory of random networks was first introduced by mathematicians Paul Erdős and Alfréd Rényi in 1959. There are several different models for random networks. The most well known are two variants called Erdős–Rényi networks. This model shows four different ways to create random networks, 2 of which create the variants of the classic Erdős–Rényi networks.
SETUP creates NUM-NODES turtles and gives them a random location in the world. There are four different wiring methods illustrated:
WIRE1: Each turtle asks one other turtle to link to it.
WIRE2: Pick a random turtle and ask it to try to link to another random turtle. This is done NUM-NODES times.
WIRE3: The classic Erdős–Rényi random network. Creates exactly NUM-LINKS links.
WIRE4: A variant of the classic Erdős–Rényi random network. For each pair of turtles, creates a link between them wth probability WIRING-PROB.
Press SETUP to create the nodes.
Pressing any of the WIRE buttons will create random networks using the different algorithms.
For a classic Erdős–Rényi random network, set the NUM-LINKS slider and then press WIRE3 to create that number of links in your network. For a variant of the Erdős–Rényi random network that has a fixed probability for each pair of nodes to have a link, you can set the WIRING-PROB slider and then press WIRE4.
There are three monitors:
MAX-DEG shows the degree of the node with the most links.
MIN-DEG shows the degree of the node with the least links.
The #LINKS monitor shows the total number of links in the network.
For each of the four wiring methods, what kind of structure does the resulting network have?
Does each method produce the same number of links each time? How do the MIN-DEGREE and MAX-DEGREE vary across the wiring methods?
For the two variants of the Erdős–Rényi random network, do the min and max degrees follow the number of links proportionally? Can you think of why or why not?
Use the bundled NetLogo network extension and run some basic network metrics on the various random networks. Are they structurally similar? If not, how are they different?
See other models in the Networks section of the Models Library, such as Preferential Attachment.
See also Network Example, in the Code Examples section of the Models Library.
Nodes are turtle agents and edges are link agents.
The maximum value for the NUM-LINKS slider is dynamic. This is done in order to prevent the model from ending up in an infinite while-loop in the WIRE3 procedure. The maximum value is either 1000, or the (number of nodes * the number of nodes / 2), whichever is smaller.
Though it is not used in this model, there exists a network extension for NetLogo (bundled with NetLogo) that has many more network primitives.
Finally, in the WIRE4 procedure, we use the following code to loop through each pair of turtles:
ask turtles [ ask turtles with [ who > [ who ] of myself ] [ ;; do something for that pair of turtles ] ]
This is of the few situations where using the WHO number (which uniquely identifies a turtle) can be handy: by having each turtle from the outer loop asking only turtles with a greater WHO number than itself in the inner loop, we make sure that each possible pair of turtles if considered only once.
This model is part of the textbook, “Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo.”
If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.
For the model itself:
Please cite the NetLogo software as:
Please cite the textbook as:
Copyright 2008 Uri Wilensky.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at email@example.com.