Link Breeds Example
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This code example shows how to create different kinds of links using link breeds.
The idea of link breeds is based on turtle breeds; both turtles and links can come in different breeds.
Note that many models that use links don't need link breeds. If a model only has one kind of link, the links can be generic, unbreeded links.
THINGS TO NOTICE
Each link breed is either directed or undirected. When you create the breed, you must specify one or the other.
Two undirected links of the same breed cannot exist between the same two turtles. Two directed links of the same breed cannot exist between the same two turtles in the same direction.
Comments and Questions
;; every link breed must be declared as either directed or undirected directed-link-breed [red-links red-link] undirected-link-breed [blue-links blue-link] blue-links-own [ weight ] ;; link breeds can own variables just like turtle breeds to setup clear-all create-ordered-turtles 10 [ fd 5 set color gray ] ask n-of 5 turtles [ ;; create--with is used to make undirected links create-blue-link-with one-of other turtles [ set color blue set weight random 10 set label weight ] ] ;; different breeds can have different default shapes set-default-shape red-links "curved link" ask n-of 5 turtles [ ;; create--to/from are used to make directed links create-red-link-to one-of other turtles [ set color red ] ] end ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Link Breeds Example.png | preview | Preview for 'Link Breeds Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.