Degrees of separation in Netlogo

Viewed 40

I would like to know how I can count the degrees of separation among nodes within a network. I have created a network with two breeds that spread virus through time.

to setup
create-people_inf 5 [set label "Infected"]
create-people_well 20 [set label "Good health"]
end

Then I added new nodes to the preexisting ones as follows:

  ask people_inf
  [ create-links-to other people_inf
    [set color red ]
    let this_turtle self
    ask people_well
    [
     if random-float 1 < 0.5
     [
        create-link-to this_turtle [set color green]
    ]
    ]
  ]

This is just a default network. My question would be on how I can count the degrees of separation between one selected node and another one, randomly chosen. I thought of adding a flag and consider a logical condition (if connected?=true), but I do not know to consider the nodes in between. My approach would give me only information on one node and its directed connections.

Any suggestion is more than welcomed. Thanks.

1 Answers
Related