Preferential Attachment, Homophily etc. Networks
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
(a general understanding of what the model is trying to show or explain)
HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
THINGS TO NOTICE
(suggested things for the user to notice while running the model)
THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
Comments and Questions
turtles-own [wealth my-probability-of-homophily] globals[number-homophily number-contagion flag] extensions[nw] to setup clear-all nw:set-context turtles links ask patches [set pcolor white] create-turtles number-of-nodes [ set wealth Random 20 set shape "circle" set color scale-color green wealth -5 25 set size 1 setxy random-xcor random-ycor set my-probability-of-homophily random probability-of-homophily] reset-ticks end to go ask links [set color gray] ask one-of turtles [ make-node-homophily find-partner wealth] ; if number-homophily >= number-of-links [ask links [set color gray] ask one-of turtles [set color red] stop] tick if layout? [layout] end to contagion set flag 0 if any? turtles with [color != red and count link-neighbors > 0] [ ask turtles with [color = red] [ ask link-neighbors [if random 100 <= probability-linked-affected [set color red set flag 1] ask other turtles [ if random 100 < probability-other-affected [set color red set flag 1]] ] ] if flag = 1 [set number-contagion number-contagion + 1] ] end to make-node-homophily [node] if node != nobody [ create-link-with node [set color red] move-to node fd 8 ] set number-homophily number-homophily + 1 end to-report find-partner [W] ifelse random 100 < my-probability-of-homophily [report one-of other turtles with [wealth = W or wealth = W - 1 or wealth = W + 1]] [report one-of other turtles with [wealth > W]] end ;;;;;;;;;;;;;; ;;; Layout ;;; ;;;;;;;;;;;;;; ;; resize-nodes, change back and forth from size based on degree to a size of 1 to resize-nodes ifelse all? turtles [size <= 1] [ ;; a node is a circle with diameter determined by ;; the SIZE variable; using SQRT makes the circle's ;; area proportional to its degree ask turtles [ set size sqrt sqrt count link-neighbors ] ] [ ask turtles [ set size 1 ] ] end to layout ;; the number 3 here is arbitrary; more repetitions slows down the ;; model, but too few gives poor layouts repeat 3 [ ;; the more turtles we have to fit into the same amount of space, ;; the smaller the inputs to layout-spring we'll need to use let factor sqrt count turtles ;; numbers here are arbitrarily chosen for pleasing appearance layout-spring turtles links (1 / factor) (10 / factor) (10 / factor) display ;; for smooth animation ] ;; don't bump the edges of the world let x-offset max [xcor] of turtles + min [xcor] of turtles let y-offset max [ycor] of turtles + min [ycor] of turtles ;; big jumps look funny, so only adjust a little each time set x-offset limit-magnitude x-offset 0.1 set y-offset limit-magnitude y-offset 0.1 ask turtles [ setxy (xcor - x-offset / 2) (ycor - y-offset / 2) ] end to-report limit-magnitude [number limit] if number > limit [ report limit ] if number < (- limit) [ report (- limit) ] report number end
There is only one version of this model, created about 10 years ago by Jiawei Fu.
This model does not have any ancestors.
This model does not have any descendants.