Network Import Example
Model was written in NetLogo 5.0.4
•
Viewed 1222 times
•
Downloaded 100 times
•
Run 5 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Click to Run Model
turtles-own [node-id] links-own [strength] globals [links-list] to import-network clear-all set-default-shape turtles "circle" import-attributes layout-circle (sort turtles) (max-pxcor - 1) import-links end ;; This procedure reads in a files that contains node-specific attributes ;; including an unique identification number to import-attributes ;; This opens the file, so we can use it. file-open "attributes.txt" ;; Read in all the data in the file ;; data on the line is in this order: ;; node-id attribute1 attribute2 while [not file-at-end?] [ ;; this reads a single line into a three-item list let items read-from-string (word "[" file-read-line "]") crt 1 [ set node-id item 0 items set size item 1 items set color item 2 items ] ] file-close end ;; This procedure reads in a file that contains all the links ;; The file is simply 3 columns separated by spaces. In this ;; example, the links are directed. The first column contains ;; the node-id of the node originating the link. The second ;; column the node-id of the node on the other end of the link. ;; The third column is the strength of the link. to import-links ;; This opens the file, so we can use it. file-open "links.txt" ;; Read in all the data in the file while [not file-at-end?] [ ;; this reads a single line into a three-item list let items read-from-string (word "[" file-read-line "]") ask get-node (item 0 items) [ create-link-to get-node (item 1 items) [ set label item 2 items ] ] ] file-close end ;; Helper procedure for looking up a node by node-id. to-report get-node [id] report one-of turtles with [node-id = id] 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 9 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Network Import Example.png | preview | Preview for 'Network Import Example' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.