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 agentset is 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