Gabriel Fair
Gabriel Fair

Reputation: 4264

Is there a way to have two link types in NetLogo?

I know this question sounds like it goes against the netlogo paradigm, but I'm looking for a way for any two turtles to have more than one type of link. Lets say a blue link and a green link?

Upvotes: 2

Views: 184

Answers (1)

JenB
JenB

Reputation: 17678

Yes, just like turtles, you can have breeds of links. The following code has two breeds named green-links and blue-links. In this case, both are undirected-links but you can also have directed-links.

undirected-link-breed [green-links green-link]
undirected-link-breed [blue-links blue-link]

to testme
  clear-all
  ask patches [set pcolor white]
  create-turtles 10
  [ setxy random-xcor random-ycor
    set color red
  ]
  repeat 20
  [ ask one-of turtles
    [ create-green-link-with one-of other turtles [ set color green ] ]
  ]
  repeat 20
  [ ask one-of turtles
    [ create-blue-link-with one-of other turtles [ set color blue ] ]
  ]
end

There is nothing stopping the same pair of turtles from having multiple links between them as long as the links are of different breeds.

Upvotes: 6

Related Questions