Social Network Sharing

Social Network Sharing preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.2.0 • Viewed 681 times • Downloaded 47 times • Run 0 times
Download the 'Social Network Sharing' modelDownload this modelEmbed this model

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

; Our model must have commands that tell it to setup the model, and to run the model
; In the interface tab, add a button; In Command, write setup
; In the interface tab, add a button; In Command, write go; Check the forever and disable until ticks start boxes

; Our model relies on the user to use Sliders to determine the number of computers, number of 
; links, and likelihood of sharing an image for our model. 
; In the interface tab, add sliders for:
; number-of-computers: min=0; increment=1; max=100; value=100
; links-to-other-computers: min=0; increment=1; max=10; value=5
; likely-to-share: min=0; increment=1; max=50; value=10; unit=%

; It would be useful to know the number of times the image has been viewed and the number of times
; the image has been shared in our simulation.
; In the interface tab, add monitors for:
; numshares and numviews
; In the interface tab, add a plot:
; Name=Image sharing; x axis label=Time; y axis label=Number
; Makes ure Auto scale? and Show legend? are checked
; Plot pens: pen name: Num. Shares --> plot numshares
; Plot pens: pen name: Num. Views --> plot numviews

globals [
  computerColors 
  ; Create a variable called numshares to count the number of times the image has been shared
  numshares
  ; Create a variable called numviews to count the number of times the image has been viewed
  numviews
]

turtles-own[
  ; Create a variable called seenimage; it will be true if the computer has seen the image
  seenimage
  ; Create a variable called sharedimage; it will be true of the computer has shared the image
  sharedimage
]

; The setup procedure

to setup
  ; Clear the world
  clear-all
  ; Initialize numshares and numviews to 0
  set numshares 0
  set numviews 0 
  ; Color the background white, and 
  ask patches [set pcolor white]
  ; Initialize an array of colors for the computers
  set computerColors [ 15 25 45 65 75 85 95 115 125 135 ] 
  ; Color the links between the computers gray
  ask links [ set color 5 ]
  ; Call the setupNetwork and setup-spatially-clustered-network procedures
  setupNetwork
  setup-spatially-clustered-network
  ; Set the sharedimage and seenimage variables to false for all of the turtles (computers)
  ask turtles [ set sharedimage false set seenimage false ]
  ; One computer must start with the image
  ; Set seenimage to true, sharedimage to false, color to black, and size to 2
  ask one-of turtles [ set seenimage true set sharedimage false set color black set size 2 ]
  ; reset the clock for the model
  reset-ticks
end 

; The go procedure

to go
  ; Our program should stop when all of the computers have seen the image (when seenimage = true)
  if all? turtles [seenimage = true]
    [ stop ]
  ; To start our model, we must ask the computers to start spreading the image
  ask turtles [
    spreadimage
  ]
  ; Go to the next cycle (tick)
  tick
end 

; The setupNetwork procedure

to setupNetwork
  ; set the default shape of the turtles ("house")  
  set-default-shape turtles "house"
  ; place the desired number of computers into the model
  crt number-of-computers
  [
    ; set the color of the computers to one of the colors in the array of computerColors
    set color one-of computerColors
    ; Place the computers randomly throughout the model, but not too close to the edge
    setxy (random-xcor * 0.95) (random-ycor * 0.95)
  ]
end 

; The setup-spatially-clustered-network procedure

to setup-spatially-clustered-network
  let num-links (links-to-other-computers * number-of-computers) / 2
  while [count links < num-links ]
  [
    ask one-of turtles
    [
      let choice (min-one-of (other turtles with [not link-neighbor? myself])
                   [distance myself])
      if choice != nobody [ create-link-with choice ]
    ]
  ]
  ; make the network look a little prettier
  repeat 10
  [
    layout-spring turtles links 0.3 (world-width / (sqrt number-of-computers)) 1
  ]
end 

; The spreadimage procedure

to spreadimage
  ; A computer can spread the image if they have seen it and not shared the image before
  if seenimage = true and sharedimage = false [
    ; A computer can spread the image only a percentage of the time
    if random 100 < likely-to-share [
      ; if this is that percentage of the time, share the image!
      ; when you share the image, call viewimage because it means that all of your neighbors will see it
      ask link-neighbors [
        viewimage
      ]
      ; You've shared the image, so set sharedimage to true
      set sharedimage true
      ; Also, increase the number of shares variable by 1
      set numshares numshares + 1
    ]
  ]
end 

; The viewimage procedure

to viewimage
  ; when a computer has seen the image, change their color to black and size to 2
  set color black
  set size 2 
  ; the neighbors have seen the image, so ask them to set their seenimage variable to true
  ; This will give them a change to share the image during the next pass
  ask link-neighbors [set seenimage true]
  ; the neighbors have seen the image, so increase the number of the number of views variable by 1
  set numviews numviews + 1
end 

There is only one version of this model, created almost 10 years ago by Jennifer Dana-Farley.

Attached files

File Type Description Last updated
Social Network Sharing.png preview Preview for 'Social Network Sharing' almost 10 years ago, by Jennifer Dana-Farley Download

This model does not have any ancestors.

This model does not have any descendants.