NetLogo / NW-Extension

This is the NetLogo Network Extension. For general information about NetLogo, see:
http://ccl.northwestern.edu/netlogo/
Other
62 stars 25 forks source link

Replace `set-snapshot` with `set-context` #76

Closed nicolaspayette closed 11 years ago

SethTisue commented 11 years ago

I should remember from previous discussions and presentations, but I don't: what's the difference between set-snapshot and set-context?

nicolaspayette commented 11 years ago

From the doc:

Now wouldn't it be better if you didn't have to call nw:set-snapshot everytime you want to do something with a network? Yes, indeed, it would. And eventually, it will be the case. What we have in mind for the moment is something like a nw:set-context primitive, which you would use to tell the extension that "in general, these are the turtles and links I want to work with." Once you set the context, the extension will be wise enough to decide by itself if it needs to take a new snapshot or not.

The reason we did not do it like this right away is that there currently is no efficient way to ask NetLogo if turtles and links have been created or deleted since a previous function call. If we can include this functionality in a future version of NetLogo, we will probably deprecate nw:set-snapshot and provide the much more convenient nw:set-context instead.

Jung's implementation of Dijktra's algorithm for path finding automatically caches a distance matrix to be reused unless the graph has changed. This is something we could easily have foregone, though. The real sticking point was the centrality primitives: the algorithms that calculate centrality do it for the whole graph at once and put the results in a map from vertex to score. We could have returned this map as a list of [turtle, score] pairs, but we wanted simple turtle reporters allowing things like ask turtle 0 [ set size nw:betweenness-centrality]. And this required knowing if the score map was still valid or if we had to recalculate centrality for the whole graph.

I'm not sure I'd go with the same design decision if I could revisit it. set-snapshot was quite a hassle. But the point is moot, now: set-context will soon be ready.

SethTisue commented 11 years ago

thx

SethTisue commented 11 years ago

congrats