links

 

links are a special category of agents (like turtles and patches) in NetLogo to represent connections between turtles. A link itself is just a connection between any two (distinct) turtles with some information attached. With just this simple tool of connections between turtles, we can represent very sophisticated relationships between turtles such as family trees, "friend" relationships on social media (commonly referred to as a "social graph"), or even road maps for navigation software like Google Maps or Waze.

You can create new links between turtles using the create-link-with and create-links-with primitives. Notice that create-link-with creates only one link between two turtles and it requires a specific turtle, while create-links-with creates multiple turtles at once and requires an agentset.

ask turtles [
    create-link with one-of other turtles
    create-links-with other turtles with [color = green]
]

Things to keep in mind when using links:

In the model example below, we have a computer network represented with a server at the center and other terminal computers arranged in a circle layout. Each computer is connected to the server with a gray dashed link that represents a passive connection. At each tick, our server initiates an active connection to a random terminal. We represent the active connections with a green link. We also use two different link shapes for active connections: a simple straight link indicating an information retrieval and a curved three-line connection indicating a file download.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the links primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the links primitive:
 
 
Similar primitives:
link-neighbors

Reports all agents connected to a turtle with links.

Read more
turtles

Reports an agentset that contains all the turtles in a model.

Read more
patches

Reports an agentset that contains all the patches in a model.

Read more
create-links-with

Creates links with every agent in an agentset.

Read more
 
Learn another primitive: