# Avalanches

Simulation codes and network topologies for the examples in the paper J.P. Gleeson and R. Durrett, Temporal profiles of avalanches on networks, arXiv:1612.06477. Download the Octave/MATLAB files here. Please cite the paper if used in publications; send comments and bug reports to james.gleeson@ul.ie.

Updated: 10 Aug 2017

**Simulation codes:**

The main simulation codes are as follows:

- model_memes.m: Script to run simulations of the meme propagation model of [J.P. Gleeson et al., Phys. Rev. Lett. 112, 048701 (2014); arXiv:1305.4328].
- model_neuro.m: Script to run simulations of the neuronal dynamics model of [N. Friedman et al., Phys. Rev. Lett. 108, 208102 (2012)].
- model_threshold.m: Script to run simulations of the Centola-Macy threshold model [D. Centola and M. Macy, J. Sociology, 113, 702 (2007)].

**Subsidiary simulation codes are as follows:**

- model_memes_randrewire.m: Same dynamics as in model_memes.m, but first randomly rewires the network.
- model_memes_pjkrewire.m: Same dynamics as in model_memes.m, but first rewires the network to retain the joint distribution of in- and out-degrees, but otherwise randomize the structure.
- model_memes_nonMarkovian.m: A continuous-time generalization of the dynamics of model_memes.m, where each node waits an inter-event time \tau_n between its tweets, with \tau_n drawn from a unit-mean Weibull distribution with shape parameter k and scale parameter lambda=1/Gamma(1+1/k)

**Network topologies:**

Each network topology file is a MAT file containing a scalar N (number of nodes in network), and two vectors fromv and tov, which define the directed edges (i,j) of the unweighted network, where i=fromv(n) and j=tov(n), for n=1 to total number of edges.

- dat_network_directed_powerlaw.mat: Directed configuration-model network generated by assigning k out-stubs to each node, where k is drawn from a power-law distribution p_k with exponent 2.5 (and p_k=0 for k<4). Each out-stub is then designated to be an in-edge of a randomly-chosen node, which means that the in-degree distributions is Poisson, and the in-degree and the out-degree of a node are independent. Any self-links or multi-links are deleted.
- dat_network_directed_zregular.mat: As above, except that the out-degree distribution p_k has unit mass at k=10, meaning that every node has out-degree 10.
- dat_network_undirected_powerlaw.mat: Undirected configuration-model network generated by assigning k stubs to each node, where k is drawn from a power-law distribution p_k with exponent 3.3 (and p_k=0 for k<2). Pairs of stubs are then chosen at random to create the edges of the network. Any self-links or multi-links are deleted.
- dat_network_undirected_zregular.mat: As above, except that the degree distribution p_k has unit mass at k=3, meaning that every node has degree 3.
- dat_network_directed_SNAPtwitter.mat: Directed network created from lists on Twitter, using the twitter_combined.txt file available from the SNAP dataset repository [J. McAuley and J. Leskovec. Learning to Discover Social Circles in Ego Networks. NIPS, 2012]. We read in the (i,j) edges from the twitter_combined.txt file, reindexing the nodes from 1 to N, and delete any self-links or multi-links.

**Examples:
To reproduce the simulation results for the figures in the paper, use the following:**

- Fig. 5(a), (c) and (e): Simulations using model_memes.m, with input file dat_network_directed_powerlaw.mat
- Fig. 5(b), (d) and (f): Simulations using model_memes.m, with input file dat_network_directed_zregular.mat
- Fig. 6(a), (c) and (e): Simulations using model_neuro.m, with input file dat_network_directed_powerlaw.mat
- Fig. 6(b), (d) and (f): Simulations using model_neuro.m, with input file dat_network_directed_zregular.mat
- Fig. 7(a), (c) and (e): Simulations using model_threshold.m, with input file dat_network_undirected_powerlaw.mat
- Fig. 7(b), (d) and (f): Simulations using model_threshold.m, with input file dat_network_undirected_zregular.mat
- Fig. 8(a), (c) and (e): Simulations using model_memes.m, with input file dat_network_directed_SNAPtwitter.mat
- Fig. 8(b), (d) and (f): Simulations using model_memes_randrewire.m
- Supplementary Fig. 6: Simulations using model_memes_pjkrewire.m
- Supplementary Fig. 8(a), (c) and (e): Simulations using model_memes_nonMarkovian.m, with input file dat_network_directed_powerlaw.mat and k=0.5
- Supplementary Fig. 8(b), (d) and (f): Simulations using model_memes_nonMarkovian.m, with input file dat_network_directed_zregular.mat and k=0.5
- Supplementary Fig. 9(a), (c) and (e): Simulations using model_memes_nonMarkovian.m, with input file dat_network_directed_powerlaw.mat and k=0.4
- Supplementary Fig. 9(b), (d) and (f): Simulations using model_memes_nonMarkovian.m, with input file dat_network_directed_zregular.mat and k=0.4
- Supplementary Fig. 10(a), (c) and (e): Simulations using model_memes_nonMarkovian.m, with input file dat_network_directed_powerlaw.mat and k=0.3
- Supplementary Fig. 10(b), (d) and (f): Simulations using model_memes_nonMarkovian.m, with input file dat_network_directed_zregular.mat and k=0.3