NetLogo/models

Random Network Example: hangs when too many links

Closed this issue · 0 comments

At https://groups.google.com/forum/#!topic/netlogo-devel/XSbKq3_ec5w, Alan Isaac says:

In the Random Network Example, it is easy for the naive user to set num-links too high, producing an infinite loop in setup-simple-random.

Two possible solutions:

i. set the Maximum to num-nodes * (num-nodes - 1) / 2 in the num-links slider.

ii. add the following (or equivalent) before the while loop in setup-simple-random:

`let max-links num-nodes * (num-nodes - 1) / 2`
`if (num-links > max-links) [set num-links max-links]`