;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Chris's Network Demo ;; (C) Christopher J Watts, 2010 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; extensions [array] globals [ last-network-seed last-sim-seed num-red num-blue num-green blue-origin green-origin num-nlinks num-components max-component net-constraint clust-coeff assortativity net-density net-diameter mean-degree min-degree max-degree median-degree stdev-degree mean-cliquishness min-cliquishness max-cliquishness median-cliquishness stdev-cliquishness mean-dos min-dos max-dos stdev-dos mean-constraint min-constraint max-constraint mean-betweenness min-betweenness max-betweenness mean-localvariety sum-localvariety min-localvariety max-localvariety order-switchpoints blue-green-order num-info-errors mean-error-rate median-error-rate min-error-rate max-error-rate mean-learning median-learning min-learning max-learning ] breed [nodes node] undirected-link-breed [nlinks nlink] nodes-own [ state degree constraint cliquishness dos reach closeness betweenness component predecessors localvariety memory num-errors num-decisions agent-error-rate agent-learning ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setup clear-all setup-rng-network ask patches [ set pcolor white ] create-nodes number-of-nodes [ ; set shape "face happy" set shape "person" set size 4 ] setup-links setup-states calc-metrics setup-plots end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Random number generation to print-seeds print "Random number seeds:" print (word "Network: " last-network-seed) ; print (word "Simulation: " last-sim-seed) print " " end to setup-rng-network random-seed new-seed ifelse network-seed = 0 [ set last-network-seed random (2 ^ 31) ] [ set last-network-seed network-seed ] random-seed last-network-seed end to setup-rng-sim ; random-seed new-seed ; ifelse sim-seed = 0 ; [ set last-sim-seed random (2 ^ 31) ] ; [ set last-sim-seed sim-seed ] ; random-seed last-sim-seed end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; states: up to 2 competing technologies/ideas/diseases diffuse from distinct origins to setup-states setup-rng-sim init-states-allr ; ask nodes [ set memory [] ] ask nodes [ set memory 0 if initial-learning-chance = "Uniformly distributed" [ set agent-learning (random-float 1) ] if initial-learning-chance = "Homogeneous population" [ set agent-learning learning-chance ] set num-decisions 0 set num-errors 0 set agent-error-rate 0 ] set order-switchpoints [] set blue-green-order (num-blue > num-green) set num-info-errors 0 setup-state-plots calc-localvariety update-plot end to init-states-allr ; No initial green or blue ask nodes [ set color red set state 0 ] set num-red ((count nodes) ) set num-green 0 set num-blue 0 end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to go agent-decision tick if ticks mod output-every = 0 [ calc-localvariety update-plot ] if end-sim [ calc-localvariety update-plot stop] end to-report end-sim let halt-answer (ticks > max-ticks) report halt-answer end to calc-localvariety ask nodes [ calc-node-localvariety ] end to calc-node-localvariety ifelse (count my-nlinks) > 0 [ let root-state state set localvariety ((count nlink-neighbors with [state != root-state]) / (count nlink-neighbors)) ] [ set localvariety 0 ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to update-plot set-current-plot "infected" set-current-plot-pen "green-infected" plot num-green set-current-plot-pen "blue-infected" plot num-blue set-current-plot-pen "red-uninfected" plot num-red set-current-plot "local-variety" set-plot-x-range 0 1.1 set-plot-pen-interval 0.1 histogram [localvariety] of nodes set mean-localvariety mean [localvariety] of nodes set min-localvariety min [localvariety] of nodes set max-localvariety max [localvariety] of nodes set-current-plot "Error Rate Evolution" set mean-error-rate mean [agent-error-rate] of nodes set median-error-rate median [agent-error-rate] of nodes set min-error-rate min [agent-error-rate] of nodes set max-error-rate max [agent-error-rate] of nodes set-current-plot-pen "Mean" plotxy ticks mean-error-rate set-current-plot-pen "Median" plotxy ticks median-error-rate set mean-learning mean [agent-learning] of nodes set median-learning median [agent-learning] of nodes set min-learning min [agent-learning] of nodes set max-learning max [agent-learning] of nodes set-current-plot "Learning Histogram" histogram [agent-learning] of nodes end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setup-plots set-current-plot "degree-centrality" set-plot-x-range 0 (2 + (max [degree] of nodes)) histogram [degree] of nodes setup-loglog-plot set-current-plot "degree-of-separation" set-plot-x-range ((min [dos] of nodes)) (2 + (max [dos] of nodes)) histogram [dos] of nodes set-current-plot "betweenness-centrality" set-plot-x-range 0 1.1 set-plot-pen-interval 0.1 histogram [betweenness] of nodes set-current-plot "cliquishness" set-plot-x-range 0 1.1 set-plot-pen-interval 0.1 histogram [cliquishness] of nodes set-current-plot "structural-constraint" set-plot-x-range 0 1.1 set-plot-pen-interval 0.1 histogram [constraint] of nodes end to setup-loglog-plot let orderedlist sort ([ifelse-value (degree = 0) [0.5] [degree]] of nodes) ; NB: Some networks may have nodes with 0 links! Map them to -1 in log plot let curval first orderedlist set orderedlist but-first orderedlist let freqlist [] let vallist [] let curfreq 1 while [length orderedlist > 0] [ ifelse curval = first orderedlist [ set curfreq curfreq + 1 ] [ set vallist fput curval vallist set freqlist fput curfreq freqlist set curval first orderedlist set curfreq 1 ] set orderedlist but-first orderedlist ] set vallist fput curval vallist set freqlist fput curfreq freqlist set-current-plot "log-log" set-plot-x-range 0 int (2 + (max map [log ? 2] vallist)) set-plot-y-range 0 int (2 + (max map [log ? 2] freqlist)) ;let currank 0 ; In case we want rank-frequency plots ;set vallist reverse vallist ;set freqlist reverse freqlist while [length freqlist > 0] [ ;set currank currank + 1 set curfreq first freqlist set curval first vallist set freqlist but-first freqlist set vallist but-first vallist plotxy (log curval 2) (log curfreq 2) ] end to setup-state-plots set-current-plot "infected" clear-plot set-current-plot-pen "red-uninfected" set-plot-pen-interval output-every set-current-plot-pen "blue-infected" set-plot-pen-interval output-every set-current-plot-pen "green-infected" set-plot-pen-interval output-every end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Defining networks to setup-links if network-type = "Complete" [ setup-links-complete ] if network-type = "4-Neighbour Grid" [ setup-links-4n-grid ] if network-type = "8-Neighbour Grid" [ setup-links-8n-grid ] if network-type = "Linear" [ setup-links-linear ] if network-type = "2-Neighbour Ring" [ setup-links-2n-ring ] if network-type = "4-Neighbour Ring" [ setup-links-4n-ring ] if network-type = "10-Neighbour Ring" [ setup-links-10n-ring ] if network-type = "Star" [ setup-links-star ] if network-type = "Social Circles" [ setup-links-socialcircles ] if network-type = "Random (Erdos-Renyi)" [ setup-links-erdos-renyi ] if network-type = "Scale-free (Barabasi-Albert)" [ setup-links-barabasi-albert ] if network-type = "Scale-free (BOB)" [ setup-links-bob ] if rewire-chance > 0 [ rewire-links ] set num-nlinks (count nlinks) ask nlinks [ set color grey ] end to setup-links-complete reposition-nodes-circle ask nodes [ create-nlinks-with other nodes ] end to setup-links-2n-ring ; 2 neighbours (1 neighbour each side) let num-nodes (count nodes) let orderedlist (sort nodes) layout-circle orderedlist (max-pxcor * 0.4) foreach orderedlist [ ask ? [ create-nlink-with node ((who + 1) mod num-nodes) ] ] end to setup-links-4n-ring ; 4 neighbours (2 neighbours each side) let num-nodes (count nodes) let orderedlist (sort nodes) layout-circle orderedlist (max-pxcor * 0.4) foreach orderedlist [ ask ? [ create-nlink-with node ((who + 1) mod num-nodes) create-nlink-with node ((who + 2) mod num-nodes) ] ] end to setup-links-10n-ring ; 10 neighbours (5 neighbours each side) ; As used with 1000 nodes by Strogatz, S & Watts, D (1998) let num-nodes (count nodes) let orderedlist (sort nodes) layout-circle orderedlist (max-pxcor * 0.4) foreach orderedlist [ ask ? [ create-nlink-with node ((who + 1) mod num-nodes) create-nlink-with node ((who + 2) mod num-nodes) create-nlink-with node ((who + 3) mod num-nodes) create-nlink-with node ((who + 4) mod num-nodes) create-nlink-with node ((who + 5) mod num-nodes) ] ] end to setup-links-linear ; 2 neighbours each side let orderedlist (sort nodes) layout-circle orderedlist (max-pxcor * 0.4) foreach but-last orderedlist [ ask ? [ create-nlink-with node (who + 1) ] ] end to setup-links-star let outerset (but-first (sort nodes)) layout-circle outerset (max-pxcor * 0.4) ask node 0 [ set xcor (max-pxcor / 2) set ycor (max-pycor / 2) create-nlinks-with other nodes ] end to setup-links-socialcircles ask nodes [ setxy random-xcor random-ycor ] ask nodes [ create-nlinks-with other nodes in-radius link-radius ] end to setup-links-4n-grid reposition-nodes-grid let numnodes (count nodes) let numcols int sqrt numnodes if (numcols ^ 2) < numnodes [set numcols numcols + 1] let numrows int (numnodes / numcols) if (numcols * numrows) < numnodes [set numrows numrows + 1] let xspace (max-pxcor / (numcols + 1)) let yspace (max-pycor / (numrows + 1)) ask nodes [ create-nlinks-with other nodes in-radius (1.1 * (max (list xspace yspace))) ] end to setup-links-8n-grid reposition-nodes-grid let numnodes (count nodes) let numcols int sqrt numnodes if (numcols ^ 2) < numnodes [set numcols numcols + 1] let numrows int (numnodes / numcols) if (numcols * numrows) < numnodes [set numrows numrows + 1] let xspace (max-pxcor / (numcols + 1)) let yspace (max-pycor / (numrows + 1)) ask nodes [ create-nlinks-with other nodes in-radius (1.1 * (sqrt ((xspace ^ 2) + (yspace ^ 2)))) ] end to setup-links-erdos-renyi reposition-nodes-circle let num-nodes (count nodes) let num-links int (0.5 + (link-chance * (num-nodes * (num-nodes - 1) / 2))) while [num-links > 0] [ ask one-of nodes [ if (count my-nlinks) < (num-nodes - 1) [ ask one-of other nodes [ if not (nlink-neighbor? myself) [ create-nlink-with myself [ set num-links num-links - 1 ] ] ] ] ] ] end to setup-links-barabasi-albert reposition-nodes-circle let orderedlist sort nodes let num-nodes (count nodes) let destinations array:from-list n-values num-nodes [-1] let num-links 0 set orderedlist but-first orderedlist let chosennode 0 ask first orderedlist [ create-nlink-with node chosennode ] array:set destinations num-links chosennode while [num-links < (num-nodes - 2)] [ set chosennode ((random (2 * (num-links + 1))) - num-links) if chosennode < 0 [ set chosennode (array:item destinations (abs chosennode)) ] set num-links num-links + 1 set orderedlist but-first orderedlist ask first orderedlist [ create-nlink-with node chosennode ] array:set destinations num-links chosennode ] end to setup-links-bob ; Attempts to generate networks with right-skew degree distributions ; using the method of Bentley, Ormerod & Batty (2009) reposition-nodes-circle let orderedlist sort nodes let num-nodes (count nodes) let max-num-links (num-nodes * (num-nodes - 1)) let mem-size (2 * link-batch-size * link-memory) ; let mem-size max-num-links let destinations array:from-list n-values mem-size [-1] let num-added 0 let ego nobody let alter nobody repeat int (num-initial-pairs) [ set ego first orderedlist set orderedlist but-first orderedlist set alter first orderedlist set orderedlist but-first orderedlist ask ego [ create-nlink-with alter ] array:set destinations num-added [who] of ego array:set destinations (num-added + 1) [who] of alter set num-added (num-added + 2) ] let mptr num-added let num-to-choose-from num-added while [(length orderedlist > 0) and (num-added < max-num-links)] [ repeat (link-batch-size) [ ; set ego ifelse ((random-float 1 < new-node-chance) and (length orderedlist > 0))[ set ego first orderedlist set orderedlist but-first orderedlist set alter (node array:item destinations ((mptr - 1 - (random num-to-choose-from) + mem-size) mod mem-size)) ] [ set ego (node array:item destinations ((mptr - 1 - (random num-to-choose-from) + mem-size) mod mem-size)) ; set alter set alter ego while [ego = alter] [ ifelse ((random-float 1 < new-node-chance) and (length orderedlist > 0)) [ set alter first orderedlist set orderedlist but-first orderedlist ] [ set alter (node array:item destinations ((mptr - 1 - (random num-to-choose-from) + mem-size) mod mem-size)) ] ] ] ; create link ask ego [ create-nlink-with alter ] array:set destinations (num-added mod mem-size) [who] of ego array:set destinations ((num-added + 1) mod mem-size) [who] of alter set num-added (num-added + 2) ] set mptr ((mptr + (2 * link-batch-size)) mod mem-size) set num-to-choose-from ifelse-value (num-added > mem-size) [mem-size] [num-added] ] end to rewire-links let num-nodes-1 ((count nodes) - 1) ask n-of (rewire-chance * (count nlinks)) nlinks [ if ([count my-nlinks] of end1) < num-nodes-1 [ ask end1 [ ; create-nlink-with one-of other nodes create-nlink-with one-of other nodes with [not nlink-neighbor? myself] ] die ] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Repositioning an already created network to reposition-nodes-spring ;layout-spring turtle-set link-set spring-constant spring-length repulsion-constant repeat 10 [layout-spring nodes nlinks 0.2 (1.5 * max-pxcor / (sqrt count nodes)) 1] end to reposition-nodes-circle layout-circle (sort nodes) (max-pxcor * 0.4) end to reposition-nodes-grid let numnodes (count nodes) let numcols int sqrt numnodes if (numcols ^ 2) < numnodes [set numcols numcols + 1] let numrows int (numnodes / numcols) if (numcols * numrows) < numnodes [set numrows numrows + 1] let xspace (max-pxcor / (numcols + 1)) let yspace (max-pycor / (numrows + 1)) let orderedset sort nodes foreach orderedset [ ask ? [ set xcor (xspace * (1 + (who mod numcols))) set ycor (yspace * (1 + int (who / numcols))) ] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Calculate various node and network metrics to calc-metrics calc-degree calc-components set net-density (2 * (count nlinks) / ((count nodes) * ((count nodes) - 1))) ifelse calculate-slow-metrics [ calc-net-constraint calc-cliquishness calc-assortativity calc-betweenness ] [ calc-dos ] end to calc-degree ; Degree centrality = # links ask nodes [ set degree (count my-nlinks) ] set mean-degree mean [degree] of nodes set min-degree min [degree] of nodes set max-degree max [degree] of nodes set median-degree median [degree] of nodes set stdev-degree standard-deviation [degree] of nodes end to calc-net-constraint let csum 0 let cij 0 ask nodes [ let degi (count my-nlinks) let origin self set csum 0 ask nlink-neighbors [ ; direct or (direct and indirect) set cij (1 / degi) let dest self ask [nlink-neighbors] of origin [ if (nlink-neighbor? dest) [ set cij (cij + (1 / (degi * (count my-nlinks)))) ] ] set csum (csum + (cij ^ 2)) ; ; indirect and not direct ; set cij 0 ; let degq (count nlinks) ; ask [nlink-neighbors] of self [ ; if (not nlink-neighbor? origin) [ ; if self != origin [ ; set cij (cij + (1 / (degi * degq))) ; ] ; ] ; ] ; set csum (csum + (cij ^ 2)) ] set constraint csum ] set net-constraint sum [constraint] of nodes set mean-constraint mean [constraint] of nodes set min-constraint min [constraint] of nodes set max-constraint max [constraint] of nodes end to calc-cliquishness ; Node cliquishness = proportion of 2-stars that are triangles ; Clustering coefficient: what proportion of triplets are in fact triangles let origin node 0 let num-triangles 0 let num-2stars 0 let tot-num-triangles 0 let tot-num-2stars 0 let temp-neighbors nobody ask nodes [ set num-triangles 0 set num-2stars 0 ; cliquishness = proportion of 2-stars that are triangles set temp-neighbors nlink-neighbors ask temp-neighbors [ set origin self ask temp-neighbors [ if nlink-neighbor? origin [ if (origin != self) [ set num-triangles num-triangles + 1 ] ] ] ] set num-2stars (count nlink-neighbors) * ((count nlink-neighbors) - 1) ifelse (num-2stars = 0) [ set cliquishness 0 ] [ set cliquishness (num-triangles / num-2stars) ] set tot-num-triangles tot-num-triangles + num-triangles set tot-num-2stars tot-num-2stars + num-2stars ] set mean-cliquishness mean [cliquishness] of nodes set min-cliquishness min [cliquishness] of nodes set max-cliquishness max [cliquishness] of nodes set median-cliquishness median [cliquishness] of nodes set stdev-cliquishness standard-deviation [cliquishness] of nodes if tot-num-2stars > 0 [ set clust-coeff tot-num-triangles / tot-num-2stars ] end to calc-assortativity let avg1 0 let avg2 0 let sum1 0 let sum2 0 let sum3 0 ask nodes [ set sum1 sum1 + ((count nlink-neighbors) * degree) set sum3 sum3 + (count nlink-neighbors) ask nlink-neighbors [ set sum2 sum2 + degree ] ] ifelse (sum3 > 0) [ set avg1 sum1 / sum3 set avg2 sum2 / sum3 set sum1 0 set sum2 0 set sum3 0 let temp-diff 0 ask nodes [ set temp-diff (degree - avg1) set sum2 sum2 + ((count nlink-neighbors) * (temp-diff ^ 2)) ask nlink-neighbors [ set sum1 sum1 + (temp-diff * (degree - avg2)) set sum3 sum3 + ((degree - avg2) ^ 2) ] ] ifelse sum2 * sum3 > 0 [ set assortativity sum1 / (sqrt (sum2 * sum3)) ] [ set assortativity 0 ] ] [ set assortativity 0 ] end to calc-betweenness ; Ulrik Brandes's betweenness algorithm ; let CB array:from-list n-values (count nodes) [0] let S [] ; Stack (LIFO) let Q [] ; Queue (FIFO) let R array:from-list n-values (count nodes) [0] ; # paths let d array:from-list n-values (count nodes) [0] ; distance ;let P array:from-list n-values (count nodes) [0] ; Predecessor list let dep array:from-list n-values (count nodes) [0] let v node 0 let v-who 0 let w node 0 let w-who 0 let maxdos 0 ; let denominator (((count nodes) - 1) * ((count nodes) - 2) / 2) let denominator ((count nodes) - 1) * ((count nodes) - 2) set net-diameter -1 ask nodes [ set S [] ask nodes [ set predecessors [] ] ;set P [] set R array:from-list n-values (count nodes) [0] array:set R who 1 set d array:from-list n-values (count nodes) [-1] array:set d who 0 set Q [] set Q lput self Q while [length Q > 0] [ set v first Q set Q but-first Q set S fput v S set v-who [who] of v ask [nlink-neighbors] of v [ if (array:item d who) < 0 [ set Q lput self Q array:set d who (1 + array:item d v-who) ] if (array:item d who) = (1 + array:item d v-who) [ array:set R who ((array:item R who) + (array:item R v-who)) set predecessors fput v predecessors ;set P fput v P ] ] ] set dep array:from-list n-values (count nodes) [0] while [(length S) > 0] [ set w first S set S but-first S set w-who [who] of w foreach [predecessors] of w [ ask ? [ array:set dep who (array:item dep who) + (((array:item R who) / (array:item R w-who)) * (1 + array:item dep w-who)) ] ] if w != self [ array:set CB w-who ((array:item CB w-who) + (array:item dep w-who)) ] ] set reach sum map [ifelse-value (? >= 0) [1] [0]] (array:to-list d) set dos (sum (array:to-list d)) / reach set closeness ifelse-value (dos <= 0) [-1] [(reach - 1) / (dos * reach)] set maxdos max (array:to-list d) if (maxdos > net-diameter) [ set net-diameter maxdos ] ] ask nodes [ set betweenness (array:item CB who) / denominator ] set mean-dos mean [dos] of nodes set min-dos min [dos] of nodes set max-dos max [dos] of nodes set stdev-dos standard-deviation [dos] of nodes set mean-betweenness mean [betweenness] of nodes set min-betweenness min [betweenness] of nodes set max-betweenness max [betweenness] of nodes end to calc-dos ; From Ulrik Brandes's betweenness algorithm ; let Q [] ; Queue (FIFO) let d array:from-list n-values (count nodes) [0] ; distance let v node 0 let v-who 0 let maxdos 0 set net-diameter -1 ask nodes [ set d array:from-list n-values (count nodes) [-1] array:set d who 0 set Q [] set Q lput self Q while [length Q > 0] [ set v first Q set Q but-first Q set v-who [who] of v ask [nlink-neighbors] of v [ if (array:item d who) < 0 [ set Q lput self Q array:set d who (1 + array:item d v-who) ] ] ] set reach sum map [ifelse-value (? >= 0) [1] [0]] (array:to-list d) set dos (sum (array:to-list d)) / reach set closeness ifelse-value (dos <= 0) [-1] [(reach - 1) / (dos * reach)] set maxdos max (array:to-list d) if (maxdos > net-diameter) [ set net-diameter maxdos ] ] set mean-dos mean [dos] of nodes set min-dos min [dos] of nodes set max-dos max [dos] of nodes set stdev-dos standard-deviation [dos] of nodes end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to calc-components ; Calculate a network component for each node, and the size of the largest component let nodestack [] let tempnode node 0 let num-members 0 set num-components 0 set max-component 0 ask nodes [ set component 0] ask nodes [ if (component = 0) [ set nodestack [] set num-components num-components + 1 if (num-members > max-component) [set max-component num-members] set num-members 1 set component num-components ask nlink-neighbors with [component = 0] [ set nodestack fput self nodestack ] while [not empty? nodestack] [ set tempnode first nodestack set nodestack but-first nodestack ask tempnode [ if (component = 0) [ set component num-components set num-members num-members + 1 ask nlink-neighbors with [component = 0] [ set nodestack fput self nodestack ] ] ] ] ] ] if (num-members > max-component) [set max-component num-members] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to agent-decision ; Agents uses its memory of past actions by it and its neighbours to decide state ask one-of nodes [ let diff 0 ifelse random-float 1 < agent-learning [ ; set diff (sum memory) set diff memory if diff > 1 [ agent-acts 1 0 stop ] if diff < -1 [ agent-acts -1 0 stop ] ] [ ; Not using learning from others set diff 0 ] let source-signal (ifelse-value (random-float 1 < ifelse-value ((int (ticks / switch-source-every) mod 2) = 0) [source-chance] [1 - source-chance] ) [1] [-1]) set diff diff + source-signal if diff >= 1 [ agent-acts 1 source-signal stop ] if diff <= -1 [ agent-acts -1 source-signal stop ] ; diff = 0 agent-acts (ifelse-value (random-float 1 < 0.5) [1] [-1]) source-signal ; coin toss ] end to agent-acts [given-decision source-signal] let decision given-decision if random-float 1 < noise-chance [ set decision 0 - decision ] let decstate ((decision + 1) / 2) + 1 set num-decisions num-decisions + 1 ifelse decstate = 2 [ if (ifelse-value ((int (ticks / switch-source-every) mod 2) = 0) [source-chance] [1 - source-chance]) < 0.5 [ set num-info-errors num-info-errors + 1 set num-errors num-errors + 1 set agent-error-rate (num-errors / num-decisions) if fatal-chance > random-float 1 [make-fatal-error] ] ] [ if (ifelse-value ((int (ticks / switch-source-every) mod 2) = 0) [source-chance] [1 - source-chance]) > 0.5 [ set num-info-errors num-info-errors + 1 set num-errors num-errors + 1 set agent-error-rate (num-errors / num-decisions) if fatal-chance > random-float 1 [make-fatal-error] ] ] if state != decstate [ ifelse state = 0 [ set num-red num-red - 1 set state decstate ifelse state = 1 [ set num-green num-green + 1 set color green ] [ set num-blue num-blue + 1 set color blue ] ] [ set state decstate ifelse state = 1 [ set num-blue num-blue - 1 set num-green num-green + 1 set color green ] [ set num-blue num-blue + 1 set num-green num-green - 1 set color blue ] ] ] ; if (num-blue > num-green) != blue-green-order [ ; set blue-green-order (num-blue > num-green) ; if ticks >= switch-source-every [ ; set order-switchpoints fput ticks order-switchpoints ; ] ; ] ; let diff (sum memory) let diff memory ifelse source-signal != 0 [ set memory decision + memory ] [ ; ifelse (abs diff) > 1 [ ; Predictable ; if (diff / (abs diff)) != decision [ ; Surprising ; ; set memory fput decision memory ; set memory decision + memory ; ] ; ] ; [ ; ; set memory fput decision memory ; set memory decision + memory ; ] ] ask nlink-neighbors [ ; set diff (sum memory) set diff memory ifelse (abs diff) > 1 [ ; Predictable if (diff / (abs diff)) != decision [ ; Surprising ; set memory fput decision memory set memory decision + memory ] ] [ ; set memory fput decision memory set memory decision + memory ] ] end to make-fatal-error ; Error was fatal. Agent "dies" to be replaced with a clone of another agent. set num-decisions 0 set num-errors 0 set agent-error-rate 0 set memory 0 set color red set agent-learning [agent-learning] of one-of other nodes end to update-error-plots set-current-plot "Errors" clear-plot ask nodes [plotxy agent-learning agent-error-rate] end @#$#@#$#@ GRAPHICS-WINDOW 210 10 620 441 -1 -1 4.0 1 10 1 1 1 0 0 0 1 0 99 0 99 0 0 1 ticks INPUTBOX 8 91 102 151 number-of-nodes 100 1 0 Number INPUTBOX 8 159 102 219 link-radius 20 1 0 Number BUTTON 123 285 187 318 Setup setup NIL 1 T OBSERVER NIL NIL NIL NIL TEXTBOX 10 16 208 60 Chris's Information Cascades Network Demo 18 0.0 1 PLOT 639 462 839 612 degree-centrality Degree # Nodes 0.0 10.0 0.0 10.0 true false PENS "default" 1.0 1 -16777216 true MONITOR 917 461 977 506 Average mean-degree 2 1 11 MONITOR 985 460 1045 505 Stdev stdev-degree 3 1 11 MONITOR 846 513 908 558 Min min-degree 17 1 11 MONITOR 917 512 977 557 Median median-degree 17 1 11 MONITOR 985 511 1045 556 Max max-degree 17 1 11 TEXTBOX 847 466 915 513 Degree Centrality Statistics 11 0.0 1 BUTTON 135 367 207 400 Spring reposition-nodes-spring T 1 T OBSERVER NIL NIL NIL NIL PLOT 639 811 839 961 cliquishness Node Cliquishness # Nodes 0.0 10.0 0.0 10.0 true false PENS "default" 1.0 1 -16777216 true MONITOR 917 826 979 871 Average mean-cliquishness 3 1 11 MONITOR 847 877 909 922 Min min-cliquishness 3 1 11 MONITOR 986 877 1046 922 Max max-cliquishness 3 1 11 TEXTBOX 847 823 913 879 Cliquishness\n(Triangles / 2-Stars) 11 0.0 1 BUTTON 32 430 97 463 Go go T 1 T OBSERVER NIL NIL NIL NIL PLOT 626 11 986 182 infected Time (ticks) # Infected 0.0 10.0 0.0 10.0 true true PENS "blue-infected" 1.0 0 -13345367 true "green-infected" 1.0 0 -10899396 true "red-uninfected" 1.0 0 -2674135 true MONITOR 626 187 683 232 # Blue num-blue 17 1 11 MONITOR 688 187 747 232 # Green num-green 17 1 11 MONITOR 750 187 807 232 # Red num-red 17 1 11 MONITOR 917 877 980 922 Median median-cliquishness 3 1 11 MONITOR 986 826 1043 871 Stdev stdev-cliquishness 3 1 11 MONITOR 639 304 726 349 # Components num-components 17 1 11 INPUTBOX 990 11 1073 71 output-every 100 1 0 Number MONITOR 731 304 834 349 Largest component max-component 17 1 11 MONITOR 639 352 726 397 Density net-density 3 1 11 SWITCH 638 401 815 434 calculate-slow-metrics calculate-slow-metrics 1 1 -1000 MONITOR 873 305 976 350 Clustering Coeff. clust-coeff 3 1 11 MONITOR 873 403 976 448 Assortativity assortativity 3 1 11 PLOT 638 617 838 767 degree-of-separation DOS # Nodes 0.0 10.0 0.0 10.0 true false PENS "default" 1.0 1 -16777216 true PLOT 639 965 839 1115 betweenness-centrality Betweenness # Nodes 0.0 10.0 0.0 10.0 true false PENS "default" 1.0 1 -16777216 true MONITOR 731 352 834 397 Network Diameter net-diameter 17 1 11 MONITOR 912 617 972 662 Average mean-dos 3 1 11 MONITOR 976 617 1033 662 Stdev stdev-dos 3 1 11 MONITOR 912 667 972 712 Min min-dos 3 1 11 MONITOR 976 667 1033 712 Max max-dos 3 1 11 TEXTBOX 841 617 912 659 Mean Degree of Separation 11 0.0 1 MONITOR 913 966 973 1011 Average mean-betweenness 3 1 11 MONITOR 913 1015 973 1060 Min min-betweenness 3 1 11 MONITOR 976 1015 1033 1060 Max max-betweenness 3 1 11 TEXTBOX 841 965 908 1011 Betweenness Centrality 11 0.0 1 BUTTON 3 367 68 400 Circle reposition-nodes-circle NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 71 367 132 400 2-D Grid reposition-nodes-grid NIL 1 T OBSERVER NIL NIL NIL NIL CHOOSER 8 223 211 268 network-type network-type "Complete" "4-Neighbour Grid" "8-Neighbour Grid" "Linear" "2-Neighbour Ring" "4-Neighbour Ring" "10-Neighbour Ring" "Star" "Random (Erdos-Renyi)" "Social Circles" "Scale-free (Barabasi-Albert)" "Scale-free (BOB)" 2 TEXTBOX 3 348 153 366 Reposition Nodes 11 0.0 1 INPUTBOX 106 159 199 219 link-chance 0.1 1 0 Number INPUTBOX 8 272 101 332 rewire-chance 0 1 0 Number MONITOR 124 97 188 142 # Links num-nlinks 17 1 11 BUTTON 990 78 1054 111 Setup setup NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 990 115 1055 148 Infect go T 1 T OBSERVER NIL NIL NIL NIL PLOT 1082 11 1316 161 local-variety Proportion Neighbours Matching # Nodes 0.0 10.0 0.0 10.0 true false PENS "default" 1.0 1 -16777216 true TEXTBOX 1082 165 1309 200 Local Variety: What proportion of your neighbours have different values to you? 11 0.0 1 MONITOR 1081 200 1145 245 Min min-localvariety 3 1 11 MONITOR 1149 200 1209 245 Average mean-localvariety 3 1 11 MONITOR 1213 200 1270 245 Max max-localvariety 3 1 11 TEXTBOX 844 561 1049 617 Degree Centrality: a node's degree of connectivity = the number of links to other nodes. 11 0.0 1 TEXTBOX 843 717 1047 773 Degrees of Separation: A node's DOS is the mean length of shortest paths to other nodes. 11 0.0 1 TEXTBOX 847 925 1045 967 Cliquishness: Proportion of 2-stars with node at centre that are also triangles. 11 0.0 1 TEXTBOX 842 1064 1032 1120 Betweenness: Mean proportion of shortest paths between pairs of other nodes that go via this node. 11 0.0 1 MONITOR 873 354 976 399 Network Constraint net-constraint 3 1 11 BUTTON 991 152 1075 185 Clear state setup-states NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 99 430 197 463 Clear states setup-states NIL 1 T OBSERVER NIL NIL NIL NIL TEXTBOX 6 409 156 427 Simulate epidemics 11 0.0 1 INPUTBOX 8 524 107 584 max-ticks 100000 1 0 Number CHOOSER 8 476 182 521 when-to-halt when-to-halt "Max ticks reached" 0 TEXTBOX 636 283 786 301 Network Metrics: 11 0.0 1 TEXTBOX 871 285 985 303 Slow Network Metrics: 11 0.0 1 TEXTBOX 1071 773 1221 791 Slow Node Metrics: 11 0.0 1 TEXTBOX 639 442 789 460 Node Metrics: 11 0.0 1 PLOT 1068 795 1268 945 structural-constraint Constraint # Nodes 0.0 10.0 0.0 10.0 true false PENS "default" 1.0 1 -16777216 true BUTTON 638 771 702 804 Setup setup NIL 1 T OBSERVER NIL NIL NIL NIL MONITOR 1340 795 1400 840 Average mean-constraint 3 1 11 MONITOR 1340 845 1400 890 Min min-constraint 3 1 11 MONITOR 1405 844 1462 889 Max max-constraint 3 1 11 TEXTBOX 1271 795 1338 833 Structural Constraint 11 0.0 1 TEXTBOX 1272 896 1473 969 Constraint: Burt's measure of the mean proportion of a node's network resources invested in particular neighbours or near-neighbours. 11 0.0 1 PLOT 1049 460 1249 610 log-log log Degree log # Nodes 0.0 10.0 0.0 10.0 true false PENS "default" 1.0 2 -16777216 true INPUTBOX 8 694 110 754 new-node-chance 0.1 1 0 Number INPUTBOX 113 631 215 691 link-batch-size 10 1 0 Number INPUTBOX 8 631 110 691 num-initial-pairs 1 1 0 Number INPUTBOX 113 693 215 753 link-memory 2 1 0 Number TEXTBOX 12 615 162 633 For Scale-free (BOB) network: 11 0.0 1 INPUTBOX 9 791 111 851 network-seed 0 1 0 Number TEXTBOX 11 775 161 793 Random number stream seeds: 11 0.0 1 BUTTON 119 802 185 835 Print Seeds print-seeds NIL 1 T OBSERVER NIL NIL NIL NIL TEXTBOX 236 453 386 471 For Information Cascades: 11 0.0 1 INPUTBOX 235 476 390 536 source-chance 0.6 1 0 Number INPUTBOX 393 476 548 536 learning-chance 0.9 1 0 Number INPUTBOX 235 538 390 598 noise-chance 0 1 0 Number INPUTBOX 393 538 548 598 switch-source-every 20000 1 0 Number MONITOR 235 601 369 646 Proportion Info Errors num-info-errors / ticks 3 1 11 PLOT 1331 11 1562 240 Errors Learning Chance Error Rate 0.0 1.0 0.0 1.0 true false PENS "default" 1.0 2 -16777216 true BUTTON 1330 250 1402 283 Update update-error-plots NIL 1 T OBSERVER NIL NIL NIL NIL INPUTBOX 393 601 548 661 fatal-chance 0 1 0 Number PLOT 1330 290 1592 457 Error Rate Evolution Time (ticks) Error Rate 0.0 1.0 0.0 1.0 true true PENS "Mean" 1.0 0 -16777216 true "Median" 1.0 0 -2674135 true MONITOR 1329 483 1386 528 Mean mean-error-rate 3 1 11 MONITOR 1389 483 1446 528 Min min-error-rate 3 1 11 MONITOR 1449 483 1506 528 Median median-error-rate 3 1 11 MONITOR 1509 483 1566 528 Max max-error-rate 3 1 11 TEXTBOX 1330 465 1480 483 Agent Error Rates: 11 0.0 1 PLOT 1565 11 1765 161 Learning Histogram Learning Chance Frequency 0.0 1.1 0.0 1.0 true false PENS "default" 0.05 1 -16777216 true MONITOR 1565 164 1622 209 Mean mean-learning 3 1 11 MONITOR 1624 164 1681 209 Min min-learning 3 1 11 MONITOR 1683 164 1740 209 Median median-learning 3 1 11 MONITOR 1742 164 1799 209 Max max-learning 3 1 11 CHOOSER 360 663 548 708 initial-learning-chance initial-learning-chance "Homogeneous population" "Uniformly distributed" 0 @#$#@#$#@ WHAT IS IT? ----------- Chris's Information Cascades Network Demo Creates a network from one of several popular network types. Calculates various metrics for nodes and the network itself. Simulates decision making within the network. Decision making is based on the Information Cascades models of Bikhchandani et al. Each agent keeps a record in memory of neighbours' past decisions. An agent adds to its memory only if a neighbour's decision seems surprising to that agent, given the current state of its memory. An agent makes its own decisions either on the basis of its memory (a form of learning from others), or by consulting its own private source of information (a form of perception). Agents' decisions represent judgments about a common environmental reality and as such can be scored as successful or an error. The environment is subject to turbulence, whereby its state changes. Perceptual signals from the environment have a given degree of reliability. HOW IT WORKS ------------ Clicking "Setup" creates a network. Clicking "Go" runs a series of agent decisions, one agent decision per tick. HOW TO USE IT ------------- To create a network, enter its size in number-of-nodes, then choose a network-type from the drop-down list. (Some of these network types require extra parameters.) The network types are: (*) "Complete" - every node connects to every other node (*) "4-Neighbour Grid" - nodes are arranged on a regular 2-dimensional grid, with each node connecting to 4 neighbours (up, down, left, right) providing that these are available. Nodes at the edge have fewer neighbours. (*) "8-Neighbour Grid" - nodes are arranged on a regular 2-dimensional grid, with each node connecting to 8 neighbours (up, down, left, right, plus diagonals). (*) "Linear" - nodes form a single line. (*) "n-Neighbour Ring" - nodes are arranged in a ring, with each node connected to its n/2 nearest neighbours on each side. (*) "Star" - one central node (a hub) is connected to each of the other nodes, who are not themselves interconnected. (*) "Random (Erdos-Renyi)" - links are made between random pairs of nodes. The parameter "link-chance" controls how many links are added (actually, by setting the proportion of node pairs with a link present). (*) "Social Circles" - nodes are given random x and y coordinates, then links are added from each node to every other node within distance "link-radius" of it. (*) "Scale-free (Barabasi-Albert)" - starting with a linked pair of nodes, a network is grown by adding one new node at a time. Each new node is linked to an existing node, chosen with preference for the number of links the existing node has. The resulting distribution of links to nodes is known to be scale-free, or follow a power law. (*) "Scale-free (BOB)" - based on the method of Bentley, Ormerod & Batty (2009). Starting with a given number of linked pair of nodes, a network is grown by adding batches of new links, each with a given chance of linking a new node also. Links to existing nodes are chosen by copying a recent link, where "recent" is defined by "link-memory". Depending on the BOB model parameters, the resulting distribution of links to nodes may be scale-free (Barabasi-Albert is a special case), but can also contain clustering. In addition to the processes defined by network type, a given number of randomly chosen links may be rewired to randomly chosen nodes (a technique familiar from Watts & Strogatz's small-world networks.) "rewire-chance" determines what proportion of the links receive this rewiring. Various network metrics are calculated, including the number of network components. (Nodes connected by direct or indirect paths belong to the same component.) Some network metrics will only make sense if the network consists of one single component. There is an option to omit some of the metrics (betweenness, clustering and cliquishness), due to their requiring particularly long computation. If "Go" is clicked, a simulation runs. "infection-method" determines what the simulation consists of. Agents are initialised to have made no decision (state "red"). The simulation runs until the number of time ticks has reached the "max-ticks" value. THINGS TO NOTICE ---------------- This section could give some ideas of things for the user to notice while running the model. THINGS TO TRY ------------- BehaviorSpace contains various experiments to try. Try different network architectures. Compare final outcomes with the properties of the networks. EXTENDING THE MODEL ------------------- NETLOGO FEATURES ---------------- This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features. RELATED MODELS -------------- See the references. CREDITS AND REFERENCES ---------------------- This program (C) Christopher J Watts, 2011. See Help menu for details "About NetLogo" itself. Barabasi & Albert Strogatz & Watts Erdos & Renyi Kauffman, S. (1995) "At Home in the Universe" Wasserman, S. & K. Faust (1994) "Social Network Analysis" Hamill, L. & G. N. Gilbert (2009) Burt, R. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 0 Rectangle -7500403 true true 151 225 180 285 Rectangle -7500403 true true 47 225 75 285 Rectangle -7500403 true true 15 75 210 225 Circle -7500403 true true 135 75 150 Circle -16777216 true false 165 76 116 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 4.1.3 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ setup go timer num-nlinks num-components max-component net-density net-diameter mean-dos min-dos max-dos stdev-dos clust-coeff mean-cliquishness assortativity num-blue num-green mean-degree median-degree min-degree max-degree stdev-degree setup go timer [precision localvariety 3] of nodes [precision constraint 3] of nodes blue-origin green-origin num-blue num-green num-nlinks num-components max-component setup go true timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness min-cliquishness max-cliquishness mean-betweenness min-betweenness max-betweenness mean-constraint min-constraint max-constraint setup go true timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness min-cliquishness max-cliquishness mean-betweenness min-betweenness max-betweenness mean-constraint min-constraint max-constraint setup go timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness mean-betweenness num-blue num-green [count my-nlinks] of blue-origin [dos] of blue-origin [cliquishness] of blue-origin [constraint] of blue-origin [betweenness] of blue-origin [count my-nlinks] of green-origin [dos] of green-origin [cliquishness] of green-origin [constraint] of green-origin [betweenness] of green-origin setup go timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness mean-betweenness num-blue num-green (num-info-errors / ticks) setup go timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness mean-betweenness num-blue num-green (num-info-errors / ticks) setup go timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness mean-betweenness num-blue num-green (num-info-errors / ticks) setup go timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness mean-betweenness num-blue num-green (num-info-errors / ticks) setup go timer num-nlinks num-components max-component net-density net-diameter clust-coeff net-constraint assortativity mean-degree median-degree min-degree max-degree mean-dos min-dos max-dos mean-cliquishness mean-betweenness num-blue num-green (num-info-errors / ticks) @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 1.0 0.0 0.0 1 1.0 0.0 0.2 0 1.0 0.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@