# Complex Contagions

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

## WHAT IS IT?

This model explores the spread of behavior through social networks. Each agent follows a simple threshold rule: if enough neighbors adopt some behavior, they will adopt it as well. When only one neighbor has to be activated, the behavior is a simple contagion, and spread faster and more easily in small-world networks. When the threshold is greater than 1/k, however, it is a complex contagion and even a small amount of randomness can disrupt the spread of adoption entirely.

The goal of this model is to understand how the structure of social networks can impact the spread of behavior. A contagion can be any behavior that somebody might adopt, and the threshold captures the risk or uncertainty associated with that behavior: the higher the uncertainty, the higher the threshold.

Under some network conditions, complex contagions spread very easily. Under other conditions, however, some contagions will not spread at all! Given two otherwise identical populations, we can see that the variation in the structure of interactions can have a big impact on social outcomes.

## HOW IT WORKS

The threshold t indicates the fraction of an agent's neighbors who must be active in order for a node to become active. If an agent's has 5 neighbors and their t = 3/5, then they will be "active" if 3 or more neighbors are active, and "inactive" if 2 or fewer neighbors are active.

In this model, a contagion is "seeded" by activating a single node and all of its neighbors. Then, the contagion spreads around the network!

Here's how the contagion spreads: in each time-step, a randomly chosen non-active agent is selected. That agent activates if their threshold is met.

## HOW TO USE IT

Black nodes are inactive, and red nodes are active.

The THRESHOLD parameter determines the number of neighbors who must be active (red) in order for a node to activate (turn red).

The SETUP NETWORK button creates a "small world" network. The TOPOLOGY parameters P and N determine the probability that a tie will be rewired and the number of nodes, respectively. When P=0, a lattice network is created. When a network is created, one node and all of their neighbors are randomly selected to be active (red).

The GO button runs the model until no more nodes can be activated.

The GO ONCE button randomly selects an eligible node, and actives them.

The RESTART DIFFUSION model resets the diffusion process by randomly selecting a new seed neighborhood without changing the network topology.

The REWIRE ONE button rewires a single tie.

## THINGS TO NOTICE

Even slightly different network topoligies have substantively different collective behaviors. For example, in a ring lattice with threshold 1/2 (0.5), even a single broken tie will stop a complex contagion: try setting up a ring lattice and hitting the "rewire one" button once or a few times to see what happens.

How many ties can you rewire if THRESHOLD is less than 1/2? How do these settings impact the time it takes for the contagion to spread through the whole network?

## THINGS TO TRY

Slowly raise THRESHOLD and see what happens. What is the maximum threshold for a ring lattice?

Create a network with P=0 (a lattice network) and THRESHOLD=2. Run the diffusion model a few times. Now, rewire just a few times, and try the diffusion model a few times. What happens?

## EXTENDING THE MODEL

What happens if threshold is not homogeneous?

What happens if threshold is set so that nodes activated based on the fraction of active neighbors ("relative threshold") instead of a simple count ("absolute threshold")?

## RELATED MODELS

See the "Small Worlds With Diffusion" model that is available through the coursera course "Network Dynamics of Social Behavior" by Damon Centola.

## CREDITS AND REFERENCES

Centola, D., & Macy, M. (2007). Complex contagions and the weakness of long ties1. American Journal of Sociology, 113(3), 702-734.

## COPYRIGHT AND LICENSE

Copyright 2017 Joshua Becker

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

## Comments and Questions

;;; QUESTION: top of page 719 ... "without replacement" ?? s globals [ k ;; determines the average number of neighbors each node has this-cluster ;; a tool used by the identify-clusters procedure saturated? ;; When this is TRUE, no more agents can be activated ] turtles-own [ cluster ;; a tool used by the identify-clusters procedure distance-from-other-turtles ;; list of distances of this node from other turtles, used by the identify-clusters procedure attempted? ;; keeps track of which turtles have state-checked since a change in the system ;; the attempted? variable is used to help the model be more efficient ] links-own [ rewired? ;; keeps track of whether the link has been rewired or not, used by the rewire-all procedure ] ;; The "setup" procedure sets up the model. ;; First, it creates the network using "rewire-all." ;; Then, it seeds the contagion to setup clear-all ask patches [ set pcolor white ] set k 4 rewire-all ask turtles [ set color black set attempted? false ] set saturated? false if count turtles > 0 [ seed-contagion ] reset-ticks end ;; The "construct-agent" procedure simply constructs an agent. ;; In more complex models, a procedure like this ;; can be helpful in generating agents with many different ;; parameters or rules. to construct-agent ;; turtles-own agent constructor set shape "circle" set label "" end ;; The "restart" procedure resets the contagion process without ;; changing the network structure. to restart ask turtles [ set color black set attempted? false ] set saturated? false if count turtles > 0 [ seed-contagion ] set-current-plot "success of contagion" clear-plot reset-ticks end ;; The "run-step" procedure runs a single step of the diffusion process. ;; With each step, the model tries all the agents that are black (not red). ;; When an agent is checked, it either updates (turns red) or remains the same. ;; If the agent doesn't change, we set attempted? to TRUE for that turtle. to run-step ;; Check to see whether there are any turtles that might still become activated. ;; If not, set "saturated?" to true and stop the function. ;; If all the agents are red (none of them are black) then we know it's saturated ;; We also know it's saturated if there are zero black agents who we haven't checked already. if count turtles with [ color = black ] = 0 [ set saturated? true stop ] if count turtles with [ color = black and attempted? = false ] = 0 [ set saturated? true stop ] if not saturated? [ ask one-of turtles with [color = black ] [ let count-triggered 0 set count-triggered count link-neighbors with [color = red] ;; If enough neighbors are active (red), an inactive (black) agent will be activated. ;; Once a turtle turns from black to red, it's possible their neighbors may wish to change as well. ;; Thus, whenever a turtle is activated, we reset attempted? to false for the other turtles. ifelse count-triggered >= threshold [ set color red ask turtles with [ self != myself ] [ set attempted? false ] ] [ set attempted? true ] ] ] tick end ;; This procedure "seeds" the contagion by randomly selecting a turtle ;; and activating that turtle, as well as all of their neighbors (turning them red) to seed-contagion ask one-of turtles [ ask link-neighbors [ set color red ] set color red ] end ;; The "create-ringlat" procedure creates a new ring lattice. ;; All this procedure does is create N turtles, set their color black, ;; and then run the "wire-ringlat" procedure. to create-ringlat crt N [ set color black construct-agent ] wire-ringlat end ;; The "wire-ringlat" procedure contains the machinery needed to wire a ring lattice. ;; The parameter k determines the number of neighbors each node will have -- in this ;; version, k is fixed. However, this parameter can be turned into a variable controlled ;; from the interface. to wire-ringlat layout-circle (sort turtles) max-pxcor - 1 layout-circle (sort turtles with [ who mod 2 = 0] ) max-pxcor - 4 ;; iterate over the turtles let ni 0 while [ni < count turtles] [ ;; make edges with the next two neighbors ;; this makes a lattice with average degree of 4 let z 1 while [z <= floor (k / 2)] [ ask turtle ni [ create-link-with turtle ((ni + z) mod count turtles) [ set rewired? false ] ] set z z + 1 ] set ni ni + 1 ] end ;; the identify-clustesr and grow-clusters procedure ensure count the number of ;; components in the network. This code is inspired by the NetLogo model "Dissemination of Culture" ;; by Iain Weaver. You can find this model at: http://ccl.northwestern.edu/netlogo/models/community/Dissemination%20of%20Culture to-report identify-clusters let max-cluster 0 let num-clusters 0 let seed one-of turtles ask turtles [ set cluster nobody ] while [seed != nobody] [ ask seed [ set cluster self set num-clusters num-clusters + 1 set this-cluster 1 grow-cluster ] if this-cluster > max-cluster [ set max-cluster this-cluster] set seed one-of turtles with [cluster = nobody] ] report list num-clusters max-cluster end to grow-cluster ask link-neighbors with [cluster = nobody] [ if cluster = nobody [ set this-cluster this-cluster + 1 ] set cluster [cluster] of myself grow-cluster ] end ;; The "rewire-all" procedure generats a Small-World network according to the algorithm ;; developed by Watts & Strogatz (1998). This code is adapted from the Small Worlds NetLogo model ;; developed by Uri Wilensky. Original code Copyright 2005 Uri Wilensky. See info tab for more details. to rewire-all create-ringlat ;; set up a variable to see if the network is connected let success? false ;; if we end up with a disconnected network, we keep trying, because the APL distance ;; isn't meaningful for a disconnected network. let count-tries 0 while [not success?] [ ;; kill the old lattice, reset neighbors, and create new lattice ask links [ die ] wire-ringlat ; set number-rewired 0 ask links [ ;; whether to rewire it or not? if (random-float 1) < p [ ;; "a" remains the same let node1 end1 ;; if "a" is not connected to everybody if [ count link-neighbors ] of end1 < (count turtles - 1) [ ;; find a node distinct from node1 and not already a neighbor of node1 let node2 one-of turtles with [ (self != node1) and (not link-neighbor? node1) ] ;; wire the new edge ask node1 [ create-link-with node2 [ set color cyan set rewired? true ] ] ; set number-rewired number-rewired + 1 ;; counter for number of rewirings set rewired? true ] ] ;; remove the old edge if (rewired?) [ die ] ] set success? ( item 0 identify-clusters = 1 ) set count-tries count-tries + 1 if ( count-tries > 1000 ) [ set success? true print "couldn't make connected network! try different parameters!" ] ] end ;; This procedure rewires a single tie. to rewire-one ;; make sure num-turtles is setup correctly else run setup first if count turtles != N [ setup ] let potential-edges links with [ not rewired? ] ifelse any? potential-edges [ ask one-of potential-edges [ ;; "a" remains the same let node1 end1 ;; if "a" is not connected to everybody if [ count link-neighbors ] of end1 < (count turtles - 1) [ ;; find a node distinct from node1 and not already a neighbor of node1 let node2 one-of turtles with [ (self != node1) and (not link-neighbor? node1) ] ;; wire the new edge ask node1 [ create-link-with node2 [ set color cyan set rewired? true ] ] ;; remove the old edge die ] ] ] [ user-message "all edges have already been rewired once" ] end ;; This procedure counts the fraction (percent) of nodes who are activated (red) to-report percent-saturated report ((count turtles with [color = red ] ) / (count turtles)) end

There is only one version of this model, created about 3 years ago by Network Dynamics Group.

## Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.