Spreading Groups in Social Networks

Spreading Groups in Social Networks preview image

1 collaborator

Img_20161026_134244_(1) Alon Sela (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.3.1 • Viewed 643 times • Downloaded 37 times • Run 0 times
Download the 'Spreading Groups in Social Networks' modelDownload this modelEmbed this model

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


WHAT IS IT?

This model studies the topic of "Spreading Group". These are synchronized groups that post a message on Twitter or Facebook together, in order to increase the message`s spread. We believe such Spreading Groups are mainly constructed of bots; - computerized programs that mimic humans. The model show that such a strategy of using a spreading group of size k is more effective than reaching a similarly large number of hubs.

THE BEHAVIOR

  1. Nodes have retention loss; which is modified by the slider "size-reduction".
  2. The size of the node reflects how much time it will still be infectious.
  3. The Spreading Group is plot in an orange line within the network. Constructing the speeding groups
  4. The density of the Spreading Group is modified by the slider "spreadingGroupRepet" which determines how many additional links would be within the spreading group.
  5. It is also modified by the slider "spreading-group-percent", which determines what is the rate of nodes in the spreading group within the network.

HOW IT WORKS

The model starts with two nodes connected by an edge. At each step, a new node is added. After n/2 nodes were added, a step of formation of the spreading group is performed, followed by another n/2 steps of preferential attachment.

HOW TO USE IT

  1. Create a network by pressing after setting the network parameters. The NUM-NODES slider controls the size of the network. The GAMMA parameter determines whether the attachment is preferential (gamma = 0 means entirely preferential, gamma = 1 means entirely random). Choose num-nodes and gamma and press SETUP.

  2. Also set the and to determine the size of the spreading group.

  3. Select the which can be: a. "random" – select k nodes randomely b. "group" – select k nodes from the spreading group c. "eigenval-centrality"- select k nodes with the highest Eigenvector centrality measure. d. "PageRank-Centrality" - select k nodes with the highest PageRank centrality measure.

  4. Press the spread to inspect the spreading.Now to allow the disease to spread, you can advance on time step at a time (each infected node will infect each of its neighbors with probability p) with the "spread once" button. To let the disease run its full course, you can click the "spread" button.

THINGS TO NOTICE

  1. Chose the spread with and without the retention loss.
  2. Compare the spread by random k nodes, random k nodes from the spreading group, k nodes of the highest eigenvalues.

RELATED MODELS

See other models in the Networks section of the Models Library, such as Giant Component. See also Network Example, in the Code Examples section.

CREDITS AND REFERENCES

This model is based on: Wilensky, U. (2005). NetLogo Preferential Attachment model. Modified by Lada Adamic 2007 Modified by Alon Sela 2016 in order to inspect the topic of spreading gorups.

Comments and Questions

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

Click to Run Model

; adapted from models library by Lada Adamic (see copyright below)
; for the purposes of SI708/CSCS608
; also now contains major improvements by Eytan Bakshy

;Finally, the model is constructed by Alon Sela (2016)

extensions [nw]
globals
[
  new-node  ;; the last node we created
  degrees   ;; this is an array that contains each node in
            ;; proportion to its degree
  time
  num-infected
  previous-num-infected
  tree-mode?
  spreading-group

]

turtles-own
[
  infected?        ;; true if agent has been infected
]

;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  ;; (for this model to work with NetLogo's new plotting features,
  ;; __clear-all-and-reset-ticks should be replaced with clear-all at
  ;; the beginning of your setup procedure and reset-ticks at the end
  ;; of the procedure.)
  __clear-all-and-reset-ticks
  set tree-mode? false
  set-default-shape turtles "circle"
  set degrees []   ;; initialize the array to be empty
  ;; make the initial network of two turtles and an edge


  make-node ;; add the very first node

  let first-node new-node  ;; remember that its the first node

  ;; the following few lines create a cycle of length 5
  ;; this is just an arbitrary way to start a network

  let prev-node new-node
  repeat 4 [
    make-node ;; second node
    make-edge new-node prev-node ;; make the edge
    set degrees lput prev-node degrees
    set degrees lput new-node degrees
    set prev-node new-node
  ]
  make-edge new-node first-node

  set time 0
  set num-infected 0
  set previous-num-infected 0

  repeat (num-nodes / 2) [create-preferential-net]


  set spreading-group n-of (num-nodes * spreading-group-percent / 100 )turtles
  ask spreading-group [set color orange set size 1]
  repeat spreadingGroupRepet [create-spreading-group]

  repeat (num-nodes / 2 - 4) [create-preferential-net]
display
end 

to create-preferential-net
    no-display
    make-node  ;; add one new node

    ;; it's going to have m edges
    repeat m [
      let partner find-partner new-node      ;; find a partner for the new node
      ask partner [set color gray + 2]    ;; set color of partner to gray
      make-edge new-node partner     ;; connect it to the partner we picked before
    ]
    if layout? [ do-layout ]
    if plot? [ do-plotting ]
end 

to create-spreading-group
  ask spreading-group
    [let first-node [who] of one-of spreading-group
      let second-node [who] of one-of spreading-group
      if (first-node != second-node)
        [if not is-link? link first-node second-node [
          ask turtle first-node [
            set size 2
            create-link-with turtle second-node[
              set color orange
              set thickness 0.5]
          ]
        ]
        ]
    ]
  repeat 5 [layout-spring (spreading-group) (links with [color = red]) 5 0.5 0.5]
end 





;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Runtime Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;

; reset diffusion simulation

to reinfect-once
  clear-plot
  reset-ticks
  set num-infected num-infected-init
  set time 0
  set previous-num-infected 0
  ask turtles [set color grey
    set infected? false
    set size 1]

  if (reinfect-type = "random")
  [ask n-of num-infected-init turtles
    [set color red
      set size 2
      set infected? true
    ]
  ]

  if (reinfect-type = "group")
  [ask n-of num-infected-init spreading-group
    [set color red
      set size 2
      set infected? true
    ]
  ]

  if (reinfect-type = "eigenval-centrality")
  [ask max-n-of num-infected-init turtles [nw:eigenvector-centrality]
    [set color red
      set size 2
      set infected? true
    ]
  ]

  if (reinfect-type = "PageRank-Centrality")
    [ask max-n-of num-infected-init turtles [ nw:page-rank]
      [set color red
        set size 2
        set infected? true
      ]
    ]
end 

;; toggle infection tree mode
;; when tree-mode is on, only links responsible for contagion and infected nodes
;; are displayed. tree-mode also affects layout

to toggle-tree
  ifelse tree-mode?
  [
    ask turtles with [not infected?] [show-turtle]
    ask links with [color != red ] [show-link]
    set tree-mode? false
  ]
  [
    ask turtles with [not infected?] [hide-turtle]
    ask links with [color != red] [hide-link]
    set tree-mode? true
  ]
end 

to spread
  ;; infection can't take place while in infection tree mode
  ;; or if every agent has already been infected
  if all? turtles [infected?]
    [stop]

  ask turtles with [ infected? = true ]
  [let mysize [size] of turtle who
    let prob 0
    ;; infect neighbors
    ask link-neighbors with [infected? = false]
    [ifelse (Retention-loss = true)
      [set prob p * mysize]
      [set prob p]
    if ( random-float 1 <= prob)  ;; infect with probability p or with prob p * size
      [ set infected? true
        show-turtle
        set color red
      ;; color the link with the node doing the infection
        ask link-with myself [show-link]
        ;; increment the total number of infected agents
        set num-infected num-infected + 1
      ]
    ]
  ]

    ;; resize node so that the area is proportional to the current number of infections


  let tmp count turtles with [infected? = true]
  ifelse (tmp = previous-num-infected)
  [stop]
  [set  previous-num-infected tmp]

  forgetness
  do-plotting

  tick
end 

;; used for creating a new node

to make-node
  create-turtles 1  ;; don't know what this is - lada
  [
    set color gray + 2
    set size 0.5
    set infected? false
    set new-node self ;; set the new-node global
  ]
end 



;; Find a node to attach to
;; the degree of a node
;; 0 < gamma < 1 means gamma*100 percent of the
;; time attach randomly, rest of the time attach
;; preferentially

to-report find-partner [node1]
  ;; set a local variable called ispref that
  ;; determines if this link is going to be
  ;; preferential of not
  let ispref (random-float 1 >= gamma)

  ;; initialize partner to be the node itself
  ;; this will have to be changed
  let partner node1

  ;; if preferential attachment then choose
  ;; from our degrees array
  ;; otherwise chose one of the turtles at random
  ifelse ispref
  [
    set partner one-of degrees
   ]
   [
     set partner one-of turtles
     ]

   ;; but need to check that partner chosen isn't
   ;; the node itself and also isn't a node that
   ;; our node is already connected to
   ;; if this is the case, it will try another
   ;; partner and try again
  let checkit true
  while [checkit] [
    ask partner [
      ifelse ((link-neighbor? node1) or (partner = node1))
        [
          ifelse ispref
          [
            set partner one-of degrees
           ]
           [
             set partner one-of turtles
           ]
            set checkit true
         ]
         [
           set checkit false
         ]
       ]
    ]
  report partner
end 

;;;;;;;;;;;;;;;;;;;;;;;
;;; Edge Operations ;;;
;;;;;;;;;;;;;;;;;;;;;;;

;; connects the two turtles

to make-edge [node1 node2]
  ask node1 [
    ifelse (node1 = node2)
    [
      show "error: self-loop attempted"
    ]
    [
      create-link-with node2 [ set color grey + 2 ]
     ;; position the new node near its partner
      setxy ([xcor] of node2) ([ycor] of node2)
      rt random 360
      fd 8
      set degrees lput node1 degrees
     set degrees lput node2 degrees
     ]
  ]
end 


;;;;;;;;;;;;;;;;
;;; Plotting ;;;
;;;;;;;;;;;;;;;;

to do-plotting
     ;; plot the number of infected individuals at each step
     set-current-plot "Number infected"
     set-current-plot-pen "inf"

     plotxy ticks num-infected
end 

;;;;;;;;;;;;;;
;;; Layout ;;;
;;;;;;;;;;;;;;
;; resize-turtles, change back and forth from size based on degree to a size of 1

;; spring layout of infection tree while in tree mode
;; otherwise, layout all nodes and links

to do-layout
  ifelse tree-mode?
    [repeat 5 [layout-spring (spreading-group) (links) 5 0.5 0.5]]
    [repeat 5 [layout-spring turtles links 0.2 4 3]]
  display
end 

to forgetness
  ask turtles
    [set size size / size-reduction
      if size < 0.1 [set infected? false]
    ]
end 

; *** NetLogo 3.1.3 Model Copyright Notice ***
;
; Copyright 2005 by Uri Wilensky.  All rights reserved.
;
; Permission to use, modify or redistribute this model is hereby granted,
; provided that both of the following requirements are followed:
; a) this copyright notice is included.
; b) this model will not be redistributed for profit without permission
;    from Uri Wilensky.
; Contact Uri Wilensky for appropriate licenses for redistribution for
; profit.
;
; To refer to this model in academic publications, please use:
; Wilensky, U. (2005).  NetLogo Preferential Attachment model.
; http://ccl.northwestern.edu/netlogo/models/PreferentialAttachment.
; Center for Connected Learning and Computer-Based Modeling,
; Northwestern University, Evanston, IL.
;
; In other publications, please use:
; Copyright 2005 Uri Wilensky.  All rights reserved.
; See http://ccl.northwestern.edu/netlogo/models/PreferentialAttachment
; for terms of use.
;
; *** End of NetLogo 3.1.3 Model Copyright Notice ***

There is only one version of this model, created over 8 years ago by Alon Sela.

Attached files

File Type Description Last updated
Spreading Groups in Social Networks.png preview Preview for 'Spreading Groups in Social Networks' over 8 years ago, by Alon Sela Download

This model does not have any ancestors.

This model does not have any descendants.