NW-Extension icon indicating copy to clipboard operation
NW-Extension copied to clipboard

Conditionally select subset of network based on link values (for distance-to, path-to and turtles-in-radius)

Open EwoutH opened this issue 3 years ago • 4 comments

I would like to conditionally select a subset of a network based on link values to perform some functions, mainly distance-to, path-to and turtles-in-radius.

So for example, I have a network with links. Each link has either a red, green or blue color. I would like see which turtles are in a certain radius using only the green and blue links (so not red). Then I want to find a path those one of those turtles over only those green and blue links.

Is it currently possible to select such a subset of the network/links? If so, how? (I would expect something like with [color != red]). If not, it would be amazing to have this as an feature!

EwoutH avatar Dec 14 '22 17:12 EwoutH

@LaCuneta or @brandesNW Any chance one of you could help out with this case?

EwoutH avatar Dec 19 '22 15:12 EwoutH

@EwoutH, I think that nw:set-context does exactly what you need. Something like:

nw:set-context turtles links with [color != red]

should ensure that future calls to nw primitives will only take non-red links into account.

nicolaspayette avatar Dec 19 '22 15:12 nicolaspayette

Thanks a lot, I will try it and report back.

Do you by any chance know if there is a "move to next turtle in route and delete that item from the route (list)" function?

I'm now using:

But I feel it should be able to be done more efficiently.

EwoutH avatar Dec 19 '22 15:12 EwoutH

I think that

move-to first route
set route remove-item 0 route

is as good as it gets.

nicolaspayette avatar Dec 19 '22 15:12 nicolaspayette