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

nw:generate-preferential-attachment doesn't use proper Barabasi-Albert model #182

Closed luis-r-izquierdo closed 6 years ago

luis-r-izquierdo commented 6 years ago

Dear NetLogo developers,

I believe the documentation of procedure nw:generate-preferential-attachment is not correct. In http://ccl.northwestern.edu/netlogo/docs/nw.html#nw:generate-preferential-attachment it is said that this procedure implements Barabási–Albert algorithm, with the wikipedia link also included in the documentation.

However, if I'm not mistaken, nw:generate-preferential-attachment makes use of Jung's BarabasiAlbertGenerator, which is a different algorithm, as explained here.

Basically, the algorithm used in Jung imposes that the probability p of creating an edge between an existing vertex v and the newly added vertex is p = (degree(v) + 1) / (|E| + |V|)

whereas this probability in the original paper is: p = degree(v) / |E|

Thank you so much for your amazing work, Luis

qiemem commented 6 years ago

Good catch and thank you for reporting (and sorry for the delayed response)! I'm wondering if we should actually just replace Jung's implementation with the original BA algorithm since we don't have the same concerns with regards to isolates (since generated nodes will only be attaching to each other, and thus there are no isolates that could be attached to anyway).

The pros of removing Jung's implementation are:

The cons are:

Alternative solutions:

I'm leaning towards just changing the primitive. The number of parameters will change, so people will know that the primitive has changed in some way. If we go with the last alternative, then users will have a choice of which implementation to use, though it definitely is more complicated.

The implementation I would use would be similar to:

to generate-preferential-attachment [ num-nodes min-degree ]
  crt min-degree + 1 [
    create-links-with other turtles
  ]
  repeat (num-nodes - (min-degree + 1)) [
    crt 1 [
      repeat min-degree [
        create-link-with one-of other [ both-ends ] of one-of links
      ]
    ]
  ]
end
luis-r-izquierdo commented 6 years ago

Thank you so much for dealing with this. For what it's worth, I fully agree with all your reasoning and I share your preference. Thanks a lot, You Guys are great, Luis

weronikacwir commented 6 years ago

Is this fix included in NetLogo 6.0.2?

I ended up here because while preparing to show my classmates in Modeling & Simulation class three different ways of building preferential attachment networks in NetLogo, I noticed that my implementations of Barabási–Albert algorithm seemed to produce networks with higher maximum degrees than the nw:generate-preferential-attachment procedure. If the fix hasn't made it into NetLogo 6.0.2 then I found the answer to my problem; if it has, then I have to keep looking.

Thank you!

Weronika

luis-r-izquierdo commented 6 years ago

Hi Weronika,

I don't think so. The issue was fixed in December 2017, but NetLogo 6.0.2 was released in August 2017. https://ccl.northwestern.edu/netlogo/docs/versions.html

weronikacwir commented 6 years ago

Thank you Luis!

This solves my problem, as in: I now have the reason for the discrepancy between the results of my BA model implementation and NetLogo's, and can quit scratching my head.