Skip to content
Amin Rahimian edited this page Feb 13, 2020 · 18 revisions

We provide code to reproduce simulations and plots for our paper entitled, Long ties accelerate noisy threshold-based contagions, available here: https://arxiv.org/abs/1810.03579

The model

In models.py we implement classes for different models of contagion on networks. There are methods to generate different random graphs, simulate time series of spreading processes on them, and measure statistics of the spreading times. The basic block diagram of an agent in a network is as follows:

agent_model

The active (0.5) and inactive (-0.5) infected (1.0) states describe a situation where adopter agents may transition into a state where they are not effective in turning their neighboring non-adopters into adopters. We refer to this state as a -0.5=inactive*infected state and allow infected agents to transition back and forth between active and inactive states with probabilities alpha and gamma. We also allow a probability delta for infected agents to transition back into the susceptible state. These transitions are implemented in the step() method from class activation(contagion_model) in models.py.

The activation function block determines the type of contagion (simple or complex). Different models of contagion are characterized by different parameters. These models are implemnetd as children of class activation(contagion_model) and they override the set_activation_functions(self) method to implement a particular contagion model. For example, class SIS(activation) implements a simple contagion activation function that is parametrized by the independent transmission probability (beta) along each edge. On the other hand, class LinearThreshold(activation) implements a complex contagion activation function that is parametrized by a threshold value theta, adoption probability above threshold rho, and adoption probability below threshold q. This class has several children class RandomLinear(LinearThreshold), class RelativeLinear(LinearThreshold), class DeterministicLinear(LinearThreshold) which differ in how their threshold parameter (theta) is set.

linear_threshold_activation_function

Similarly, probit and logit activation functions are characterized by a threshold parameter theta and a noise (or rationality) parameter sigma and they are implemented by class Probit(activation) and class Logit(activation). In special cases, we make a distinction between what edges pass simple contagion adoptions (probability q) and what edges do not. Such models are not fully specified by the choice of activation functions and transition probabilities alpha, gamma, and delta, since we need to take into account the type of network edges along which transitions occur. class SimpleOnlyAlongC1(contagion_model) and class SimpleOnlyAlongOriginalEdges(contagion_model) are two such cases for which we override the step() method. In class SimpleOnlyAlongOriginalEdges(contagion_model), we allow the simple contagion probability q only if the edge connecting the adopter and non-adopter agent is existent in the original network (before rewiring or edge additions). In class SimpleOnlyAlongC1(contagion_model) we implement spreading over rewired cycle-power graphs and allow for simple contagion probability q only along the cycle edges that are not rewired.

Computing spread times

The main method to compute spread time statistics is avg_speed_of_spread() implemented in class contagion_model() in models.py.

Randomly rewired cycle-power graphs

The method avg_speed_of_spread() is used in

computing_spread_time_c1_c2_interpolation.py

computing_spread_time_c_1_union_ER.py

computing_spread_time_ck_union_ER.py

for theory simulations that measure spreading times over random graphs that are randomly rewired cycle-power graphs.

complex_contagion_spread_mechanism

rewiring_cycle_edges

A demo of complex contagion spread over cycle-power union random graph: https://youtu.be/7WNtNc-0FHk

Empirical network data

We measure the spread times over empirical social network data that are publically available online (linked in the paper). This is done in measuring_spread_time_real_networks.py. In measuring_strcutural_properties_real_networks.py we provide measurements for the geometric properties of these networks as well. The measured samples are saved in pkl files. The pickled samples are then collected in CSV by dump_properties_data.py and dump_spreading_data.py. The collected data is analyzed in R using plot_spreading_times_banerjee.R, plot_spreading_times_cai.R, plot_spreading_times_chami.R for the three data sets. The output plots are for the empirical cumulative distribution function (ECDF) of the spreading samples collected over individual villages in each dataset, as well as the aggregate ECDF over the entire data sets. We perform these measurements under various structural interventions on the original networks that include random rewiring, as well as random and triad-closing edge additions.

individual_ECDF_overlaid

Overall_ECDF_overlaid

Difference_ECDF

Clone this wiki locally