Adapting preferential attachment model

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Adapting preferential attachment model

NetLogo-Users mailing list
I'm trying to adapt the (simple) Preferential Attachment Network model (available in the Netlogo Models library) to include a slider variable that determines network structure. According to the theory of the Preferential Attachment model (or 'Opinion Leader' model) each individual in the network is assigned a number of ties, k, according to the distribution p(k) ∝ k^−γ, and connected randomly to this number of people. I thus want to have a slider for which i can adapt γ.
 
 In the heart of the original code partners and links are chosen randomly, as such:
 to create-new-nodes [n]
    clear-all
    ask patches [ set pcolor white ]
    create-nodes n [
    set color red
    set shape "circle"
  ]

    reset-ticks
end

to wire-pref-attach
  create-new-nodes 2 ; create the first two nodes (0 and 1)
  ask node 0 [ create-edge-with node 1] ; link them together
  create-nodes num-nodes - 2 [
    create-edge-with [one-of both-ends] of one-of edges ; pref select old node with more links
    set color red
    set shape "circle"
  ]
  radial-layout

end

to radial-layout
  layout-radial nodes edges (node 0)
end How should I adapt this code to include the slider for the gamma parameter?
 

 Thanks!
 

Reply | Threaded
Open this post in threaded view
|

Re: Adapting preferential attachment model

NetLogo-Users mailing list
The version of preferential attachment implemented in the model is linear (see: https://en.wikipedia.org/wiki/Preferential_attachment https://en.wikipedia.org/wiki/Preferential_attachment). Once you move away from that, as you want to do, the approach in the code is no longer viable. The idea of "using links as lottery tickets" only works for linear preferential attachment. Now you are in the business of biased coin tossing, except that the coin has n faces instead of 2.

 In a different model, I implemented a hack:
 Let k_i be the degree of node i
 Let a variable D (for denominator) be the sum of all (k_i)^(gamma)
 Iterate on the nodes; for each node i, create an edge if random-float 1.0 <= k_i ^ gamma / D
 This is a hack, because the model creates on average one link per turn. It does not create exactly one link per turn.

 

 You are welcome to adapt the code from my model (http://modelingcommons.org/account/models/2048): the routing in question is called "connect".
 

Reply | Threaded
Open this post in threaded view
|

Re: Adapting preferential attachment model

NetLogo-Users mailing list
Thanks you for your answer. I have the feeling i'm starting to understand the mechanisms behind this network. I have adapted the code to:

 to wire-pref-attach
   create-new-nodes num-nodes
   let connect? False
   let denominator (count nodes * m ^ gamma)
   let numerator (m ^ gamma)
   ask other nodes [
     if numerator / denominator > random-float 1.0 [
      set connect? true
       create-link-from myself
     ]
   ]
     radial-layout
 end

 

 

 However, when I setup the network I get the error: "There is no agent for MYSELF to refer to.
 error while node 34 running MYSELF".
 

 I'm not sure what is wrong. Any help?
 

 Thanks!