Coder Social home page Coder Social logo

threshold's Introduction

Computing the Epidemic Threshold on Temporal Networks

Provides tools for computing the epidemic threshold on temporal network, as explained in paper

Analytical Computation of The Epidemic Threshold on Temporal Networks

Valdano E, Ferreri L, Poletto C, Colizza V, Phys Rev X 5, 021005 2015.

When you use this code, please cite the above reference.

Further details on terms of use: see LICENSE

Required software

  • Python 2.7.9
  • numpy 1.9.2
  • scipy 0.15.1
  • networkx 1.9.1

Tested for the the above versions. It may work with previous/successive versions, too. It is unlikely to work with networkx 1.7 or older.

Overview

The package consists of two objects: the class tnet for uploading and managing the temporal network, and the function find_threshold, that does the job of computing the epidemic threshold.

step 1: load network with tnet

from threshold import tnet,find_threshold

In order for Python to find the library, file threshold.py needs to be in Python search path, which normally includes the working directory. Should the file be in the directory outside search path, the following code should be executed prior to the above line:

from sys import path
path.append('<directory containing file threshold.py>')

Class tnet is able to load a temporal network given in different formats:

  • path to a text file containing the whole edge list. First two columns represent edges' origin and destination, while last column is the time stamp. Time stamps are assumed to be integers from 0. If there are more than 3 columns, then 3rd column is interpreted as edge weight. Further columns between the 3rd and the last (time) are disregarded. Default separator is \t; different separators (e.g. separator=',') can be input via the optional keyword separator in the tnet constructor. By default the edge list is assumed undirected; this can be changed via the optional keyword directed in the tnet constructor.
  • (Python) list of networkx Graph or DiGraph objects. If the network is weighted, weights must be assigned to edges as weight keywords.

The network can then be loaded in class tnet as follows:

R = tnet(my_network)

Arguments for tnet, with their default values

  • my_network: where to look for the network, according to supported formats (see above);
  • period = None: set period like this, if only a part of the network is to be used, up to period T (less than the one inferred from time stamps);
  • dtype = 'float64': the bit length of the used float. In order to avoid underflow, sometimes float128 is needed. Every string that is not 'float64' is interpreted as 'float128'.
other optional keywords
  • directed: it may be used when loading from text file. If directed=True, then the edge list is assumed to be directed. If not specified, treated as directed=False;
  • separator: it may be used when loading from text file, to specify the separator. If not specified, treated as separator='\t'.

step 2: compute the threshold

compute the threshold for network R (stored as tnet object) and recovery probability mu:

threshold = find_threshold( mu , R )

Optional arguments for find_threshold, with their default values

  • vmin=0.001, vmax=0.999: range for the threshold;
  • maxiter=50: maximum number of iterations of the modified power method algorithm;
other optional keywords
  • weighted: whether to treat the network as weighted ( to know how weights are treated, see Supporting Information of ref Valdano et al). If not present, treat as weighted when the network is weighted, and unweighted when the network is unweighted.
  • findroot: can be 'bisect' or 'brentq', referring to respective functions in scipy.optimize. If not specified, treated as findroot='brentq'
  • xtol and rtol: allow to set the absolute and relative precision of the root finding algorithm. For further details see, for instance, scipy.optimize.brentq documentation.

threshold's People

Contributors

eugenio-valdano avatar

Watchers

Jurgutis Vytautas Daukantas avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.