Home
Learn NetLogo
What is NetLogo? Tutorial #0 Sample Model Tutorial #1 Models Tutorial #2 Commands Tutorial #3 Procedures
Documentation
NetLogo Dictionary Interface Guide Interface Tab Guide Info Tab Guide Code Tab Guide Programming Guide Transition Guide Preferences Guide Version History
Advanced Tools
Extension Manager Shapes Editor BehaviorSpace System Dynamics HubNet HubNet Authoring Logging Controlling Mathematica Link NetLogo 3D Cluster Computing (HPC)
Extensions
Extensions Guide Arduino Array Bitmap CSV GIS GoGo LevelSpace Matrix Networks Palette Profiler Python Resource Rnd Sound Simple R Table Time Vid View2.5D
FAQ
Home
Learn NetLogo
What is NetLogo? Tutorial #0 Sample Model Tutorial #1 Models Tutorial #2 Commands Tutorial #3 Procedures
Documentation
NetLogo Dictionary Interface Guide Interface Tab Guide Info Tab Guide Code Tab Guide Programming Guide Transition Guide Preferences Guide Version History
Advanced Tools
Extension Manager Shapes Editor BehaviorSpace System Dynamics HubNet HubNet Authoring Logging Controlling Mathematica Link NetLogo 3D Cluster Computing (HPC)
Extensions
Extensions Guide Arduino Array Bitmap CSV GIS GoGo LevelSpace Matrix Networks Palette Profiler Python Resource Rnd Sound Simple R Table Time Vid View2.5D
FAQ
primitive: create-<breed>-to, create-<breeds>-to, create-<breed>-from, create-<breeds>-from, create-<breed>-with, create-<breeds>-with, create-link-to, create-links-to, create-link-from, create-links-from, create-link-with, create-links-with
NetLogo Dictionary
  • No items found

create-<breed>-to create-<breeds>-to create-<breed>-from create-<breeds>-from create-<breed>-with create-<breeds>-with create-link-to 4.0 create-links-to 4.0 create-link-from 4.0 create-links-from 4.0 create-link-with 4.0 create-links-with 4.0

create-<breed>-to turtle

create-<breed>-to turtle commands

create-<breed>-from turtle

create-<breed>-from turtle commands

create-<breed>-with turtle

create-<breed>-with turtle commands

create-<breeds>-to turtleset

create-<breeds>-to turtleset commands

create-<breeds>-from turtleset

create-<breeds>-from turtleset commands

create-<breeds>-with turtleset

create-<breeds>-with turtleset commands

create-link-to turtle

create-link-to turtle commands

create-link-from turtle

create-link-from turtle commands

create-link-with turtle

create-link-with turtle commands

create-links-to turtleset

create-links-to turtleset commands

create-links-from turtleset

create-links-from turtleset commands

create-links-with turtleset

create-links-with turtleset commands

Turtle Command

Used for creating breeded and unbreeded links between turtles.

create-link-with creates an undirected link between the caller and agent. create-link-to creates a directed link from the caller to agent. create-link-from creates a directed link from agent to the caller.

When the plural form of the breed name is used, an agentsetis expected instead of an agent and links are created between the caller and all agents in the agentset.

The optional command block is the set of commands each newly formed link runs. (The links are created all at once then run one at a time, in random order.)

A node cannot be linked to itself. Also, you cannot have more than one undirected link of the same breed between the same two nodes, nor can you have more than one directed link of the same breed going in the same direction between two nodes.

If you try to create a link where one (of the same breed) already exists, nothing happens. If you try to create a link from a turtle to itself you get a runtime error.

to setup
clear-all
create-turtles 5
;; turtle 1 creates links with all other turtles
;; the link between the turtle and itself is ignored
ask turtle 0 [ create-links-with other turtles ]
show count links ;; shows 4
;; this does nothing since the link already exists
ask turtle 0 [ create-link-with turtle 1 ]
show count links ;; shows 4 since the previous link already existed
ask turtle 2 [ create-link-with turtle 1 ]
show count links ;; shows 5
end
directed-link-breed [red-links red-link]
undirected-link-breed
[blue-links blue-link]

to
setup
clear-all
create-turtles 5
;; create links in both directions between turtle 0
;; and all other turtles
ask turtle 0 [ create-red-links-to other turtles ]
ask turtle 0 [ create-red-links-from other turtles ]
show count links ;; shows 8
;; now create undirected links between turtle 0 and other turtles
ask turtle 0 [ create-blue-links-with other turtles ]
show count links ;; shows 12
end

Take me to the full NetLogo Dictionary.

NetLogo Dictionary: count

Documentation for the count primitive.

NetLogo Dictionary: create-ordered-turtles

Documentation for the create-ordered-turtles primitive.


NetLogo is a programmable modeling environment for simulating natural and social phenomena. It was authored by Uri Wilensky in 1999 and has been in continuous development ever since at the Center for Connected Learning and Computer-Based Modeling.

Related Links
  • NetLogo Home
  • CCL Home
  • NetLogo Web
  • NetTango Web
  • NetLogo 3D
  • BehaviorSearch
  • Contact Us

Copyright © 1999-2025 Uri Wilensky and the Center for Connected Learning and Computer-Based Modeling at Northwestern University . All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License , or (at your option) any later version.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at netlogo-commercial-admin@ccl.northwestern.edu .

For more information, visit the NetLogo website .