# Bing_Social Network Simulator_v2

Model was written in NetLogo 5.0.4
•
Viewed 502 times
•
Downloaded 29 times
•
Run 0 times

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## Comments and Questions

Please start the discussion about this model!
(You'll first need to log in.)

Click to Run Model

turtles-own [ source belong-to ;;news belong to whome ] breed [news a-news] breed [people node] to setup clear-all create-people 1 [set color red] create-people 1 [set color red create-link-with turtle 0] while [count turtles < number-of-nodes] [ setup-initial-network find-partner ] ask one-of turtles[set color pink] setup-news ask news [put-ontop] reset-ticks end to setup-nodes set-default-shape turtles "circle" create-people number-of-nodes [ setxy (random-xcor * 0.95) (random-ycor * 0.95) set color green set size 1 ] ask one-of turtles[set color pink] ;;create-news 1 [setxy random-xcor random-ycor set color yellow set shape "square"] end to setup-network let num-links (4 * number-of-nodes) / 2 while [count links < num-links] [ ask one-of people [ let choice (min-one-of (other people with [not link-neighbor? myself]) [distance myself]) if choice != nobody [create-link-with choice] ] ] ; make the network look a little prettier repeat 15 [ layout-spring turtles links 0.3 (world-width / (sqrt number-of-nodes)) 1 ] end ;;prefential attachment to setup-initial-network [old-node] create-people 1 [ set color red if old-node != nobody [ create-link-with old-node ;; position the new node near its partner move-to old-node fd 8 ] ] end to-report find-partner let total random-float sum [count link-neighbors] of turtles let partner nobody ask turtles [ let nc count link-neighbors ;; if there's no winner yet... if partner = nobody [ ifelse nc > total [ set partner self ] [ set total total - nc ] ] ] report partner end ;;;;;;;;;;;;;;;;;;;;;;;;; to setup-news create-news 1 [ set shape "car" set color yellow set size 1.5 set source one-of turtles with [color = pink] ] let temp one-of turtles with [color = pink] ask news [move-to temp set belong-to temp] end to go ifelse ticks mod 3 = 1 and ticks > 3 [ ask news [die] ask turtles [set color red] ask one-of turtles [set color pink] setup-news ] [ ask turtles with [color = pink] [ while [count link-neighbors with [color = red] > 0] [ let spread one-of link-neighbors with [color = red] let parent one-of turtles-here with [color = yellow] if spread != nobody [ if random-float 100 < news-is-interesting [ ask spread [set color pink] ask parent[hatch 1] ask parent [move-to spread set belong-to spread] ask spread [create-link-with [source] of parent] ]] ] ] ] tick end to go_once ifelse ticks mod 3 = 1 and ticks > 3 [ ask news [die] ask turtles [set color red] ask one-of turtles [set color pink] setup-news ] [ ask turtles with [color = pink] [ while [count link-neighbors with [color = red] > 0] [ let spread one-of link-neighbors with [color = red] let parent one-of turtles-here with [color = yellow] if spread != nobody [ if random-float 100 < news-is-interesting [ ask spread [set color pink] ask parent[hatch 1] ask parent [move-to spread set belong-to spread] ask spread [create-link-with [source] of parent] ]] ] ] ] tick end to put-ontop hatch 1;;[create-links-with [links]of myself] die 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) (7 / factor) (1 / 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) ] ask news [move-to [belong-to] of self] end to-report limit-magnitude [number limit] if number > limit [ report limit ] if number < (- limit) [ report (- limit) ] report number end 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 count link-neighbors ] ] [ ask turtles [ set size 1 ] ] end

There is only one version of this model, created almost 6 years ago by Bing Zhang.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Bing_June 3.pdf | Progress Report_June 3 | almost 6 years ago, by Bing Zhang | Download | |

Bing_May 13.pdf | Progress Report_May 13 | almost 6 years ago, by Bing Zhang | Download | |

Bing_May 20.pdf | Progress Report_May 20 | almost 6 years ago, by Bing Zhang | Download | |

Bing_May 27.pdf | Progress Report_May 27 | almost 6 years ago, by Bing Zhang | Download | |

Bing_Social Network Simulator_v2.png | preview | Preview for 'Bing_Social Network Simulator_v2' | almost 6 years ago, by Bing Zhang | Download |

This model does not have any ancestors.

This model does not have any descendants.