NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

  Donate

NetLogo Models Library:
IABM Textbook/chapter 5

(back to the library)

Random Network

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web

ACKNOWLEDGMENT

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.

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

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/.

WHAT IS IT?

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.

HOW IT WORKS

SETUP creates NUM-NODES turtles and gives them a random location in the world. There are four different wiring methods illustrated:

  1. WIRE1: Each turtle asks one other turtle to link to it.

  2. WIRE2: Pick a random turtle and ask it to try to link to another random turtle. This is done NUM-NODES times.

  3. WIRE3: The classic Erdős–Rényi random network. Creates exactly NUM-LINKS links.

  4. 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.

HOW TO USE IT

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:

  1. MAX-DEG shows the degree of the node with the most links.

  2. MIN-DEG shows the degree of the node with the least links.

  3. The #LINKS monitor shows the total number of links in the network.

THINGS TO NOTICE

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?

THINGS TO TRY

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?

EXTENDING THE MODEL

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?

RELATED MODELS

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.

NETLOGO FEATURES

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.

HOW TO CITE

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:

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

COPYRIGHT AND LICENSE

Copyright 2008 Uri Wilensky.

CC BY-NC-SA 3.0

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 uri@northwestern.edu.

(back to the NetLogo Models Library)