Caveman-Solaria
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
Implementation of Caveman-Solaria Worlds (Alpha Model) to simulate small-world phenomena.
HOW IT WORKS
NUMBEROFNODES is the amount of nodes we want in the network. P is a baseline propensity for an edge (i,j) to exist (default p=1*10^(-10)). The actual value of p is not important so long as it is small enough that no random edges can be expected for ALFA=0 (i.e. p << 2 / n(n-1)). K is the average degree of a graph. ALFA is a tunable parameter 0 <= ALFA <= +Inf.
HOW TO USE IT
Click SETUP and then GO.
THINGS TO NOTICE
How the topology of the network change as you change the value of ALFA?
THINGS TO TRY
EXTENDING THE MODEL
Implement rewiring process
NETLOGO FEATURES
RELATED MODELS
NetLogo Models Library: Sample Models/Networks Small Worlds by Uri Wilensky Preferential Attachment by Uri Wilensky
CREDITS AND REFERENCES
D. Watts. Networks, dynamics and the small-world phenomenon. American Journal of Sociology, 105 (2):493–527, 1999.
Comments and Questions
;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Setup Procedures ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;; to setup clear-all set-default-shape turtles "circle" create-initial-substrate reset-ticks end to create-initial-substrate create-turtles number_of_nodes ask turtles [ set color red facexy 0 0 set size 3 ] let n 0 while [n < number_of_nodes] [ make-edge turtle n turtle ((n + 1) mod count turtles) set n n + 1 ] layout-circle (sort turtles) max-pxcor - 5 end ;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Main Procedure ;;;; ;;;;;;;;;;;;;;;;;;;;;;;; to go let terminate False ;; 1 - fix a vertex i ;; ask iterate once over all turtles in random order ask turtles [ ;; 2 - for every other vertex j compute Rij according to equation: ;; 1 if mij >= k ;; (mij/k)^alfa * (1 - p) + p if k > mij > 0 ;; p if mij = 0 ;; where mij is the number of vertices that are adjacient both to i and j ;; with the additional constraint that Rij = 0 if i and j are already connected let Rij n-values (number_of_nodes)[0] let others [who] of other turtles foreach others [ ; if it is a neighbor of i we already set Rij to 0 if not link-neighbor? turtle ? [ ;; Get the number of vertices that are adjacent both to i and j ; neighbors of i let i_neighbors link-neighbors ; neigbors of j let j_neighbors [link-neighbors] of turtle ? let mij 0 foreach [who] of i_neighbors [ if member? ? ([who] of j_neighbors) [ set mij (mij + 1) ] ] ; ? variable referes to current item in others list. ; Since others list is a list of turtle IDs I can use ? as an index in Rij list. if mij >= k [ set Rij replace-item ? Rij 1 ] if mij < k and mij > 0 [ set Rij replace-item ? Rij ( (mij / k) ^ alfa * (1 - p) + p ) ] if mij = 0 [ set Rij replace-item ? Rij p ] ];; END_if ];; END_foreach ;; 3 - Sum Rij over all j, and normalize each to obtain variables Pij = Rij / Sum_l!=i Ril. ;; Then since Sum_j Pij = 1, we can interpret Pij as the probability that i will connect to j. ;; Furthermore, we can interpret Pij geometrically as follows: divide the unit interval (0,1) ;; into n - 1 half-open subintervals with length Pij for all j != i. let sum_of_Rij sum Rij let Pij map [? / ifelse-value (sum_of_Rij > 0) [sum_of_Rij] [1] ] Rij ;; 4 - A uniform random variable r is then generated on (0,1). ;; it must fall into one of the subintervals, corresponding to j* let j* (jstar others Pij) ;; 5 - Connect i to j* if j* != -1 [ make-edge turtle who turtle j* ] ;; Stop when reach this threshold if count links >= (k * number_of_nodes / 2) [ set terminate True stop ; exit ask turtles ] ];; END_ask turtles if terminate [ stop ] tick end to-report jstar [others Pij] let r random-float 1 while [ r = 0 ] [ set r random-float 1 ] ; random-float might includes 0, even though it is unlikely let partial-sum 0 foreach others [ set partial-sum partial-sum + (item ? Pij) if partial-sum > r ; it is the same as if r > partial-sum and r < (partial-sum + (item ? Pij)) [ report ? ] ] report -1 end ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Link Procedures ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ;; connects the two turtles to make-edge [node1 node2] ask node1 [ create-link-with node2 [ set color blue ] ] end to relayout ; layout-spring turtle-set link-set spring-constant spring-length repulsion-constant layout-spring turtles links 0.2 25 5 end
There is only one version of this model, created almost 11 years ago by Marcello Tomasini.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Caveman-Solaria.png | preview | Preview for 'Caveman-Solaria' | almost 11 years ago, by Marcello Tomasini | Download |
This model does not have any ancestors.
This model does not have any descendants.