Connecting or Linking Turtles from a CSV File

I have worked on a small social network model which uses an external file that contains all the information related to the person agents such as location and its list of friends. Below is the createNetwork procedure, it is executed once setup is called.

The CSV has four (4) columns in it that correspond to (a) turtles ID number, (b) x-coordinate, (c) y-coordinate and (d) a list of turtles ID numbers. In the code above, item 0 fileList is used to call a particular person agent while item 1 fileList and item 2 fileList are used as parameters for the setxy command. To establish links or connections with other person agents, item 3 fileList is processed to retrieve individual turtle ID numbers, then the create-link-with command is used.


0
-18.07
0.04514
[46 38]
1
16.11228
-18.172
[25]
2
-6.43589
-4.66438
[35 23]
3
24.55564
-3.03474
[42 39 36]
4
-5.14531
-11.8855
[43]
5
14.43445
-7.62663
[19 29]
6
-21.5105
16.77784
[14 22 34]
7
-10.1101
-6.61531
[48 43]
8
9.209351
8.759671
[40]
9
-1.54259
3.437235
[23 31]

The network will be loaded automatically afterwards.


Share on Google Plus

About SSabal

:)
    Blogger Comment
    Facebook Comment

2 comments:

  1. Hello, I'm basically new to netlogo - I got this error while trying your code.
    "nothing named CREATE-ORDERED-PERSONS has been defined" -- what's the fix to this? http://netlogoabm.blogspot.com/logout?d=https://www.blogger.com/logout-redirect.g?blogID%3D6558732268658517771%26postID%3D3836734557874167961

    ReplyDelete
  2. Debes mencionarlas como variables globales

    ReplyDelete