nw:distance-to
nw:distance-to target-turtle
Finds the shortest path to the target turtle and reports the total distance for this path, or false if no path exists in the current context. Each link counts for a distance of one.
Example:
to go
clear-all
create-turtles 5
ask turtle 0 [ create-link-with turtle 1 ]
ask turtle 1 [ create-link-with turtle 2 ]
ask turtle 0 [ create-link-with turtle 3 ]
ask turtle 3 [ create-link-with turtle 4 ]
ask turtle 4 [ create-link-with turtle 2 ]
ask turtle 0 [ show nw:distance-to turtle 2 ]
end
Will output:
(turtle 0): 2
Take me to the full Networks Extension Dictionary