benmaier / tacoma

Temporal networks in Python. Provides fast tools to analyze temporal contact networks and simulate dynamic processes on them using Gillespie's SSA.
http://tacoma.benmaier.org
Other
105 stars 7 forks source link
contact-networks epidemics face-to-face face2face network-visualization networks temporal-networks

logo

TemporAl COntact Modeling and Analysis. Provides fast tools to analyze temporal contact networks, produce surrogate networks using qualitative models and simulate Gillespie processes on them. Currently only working on OSX and Linux distributions. No Windows support yet!

Quick example

In order to download the SocioPatterns 'Hypertext 2009'-dataset and visualize it interactively, do the following.

>>> import tacoma as tc
>>> from tacoma.interactive import visualize
>>> temporal_network = tc.download_and_convert_sociopatterns_hypertext_2009()
100% [..............................................................................] 67463 / 67463
>>> visualize(temporal_network, frame_dt = 20)

visualization example

What is tacoma?

tacoma is a joint C++/Python-package for the modeling and analysis of undirected and unweighted temporal networks, with a focus on (but not limited to) human face-to-face contact networks.

Pros of using tacoma

Cons of using tacoma

Install

If you get compiling errors, make sure that pybind11 is installed.

$ git clone https://github.com/benmaier/tacoma
$ pip install ./tacoma

Note that a C++11-compiler has to be installed on the system before installing tacoma. On OS X it might happen that even though pip installed pybind11 it's not available during installation. If that happens please open a detailed issue here. You might want to try

$ brew install pybind11

as a work-around.

Packages not automatically installed during installation

The following packages are not installed during installation with pip since they're only required for drawing and drawing is not essential. If you want to use tacoma.drawing, please install

matplotlib
networkx
python-louvain (community)

Documentation

The documentation is currently available at http://tacoma.benmaier.org . It is full of typos and non-exhaustive but I think the important points are in there.

Examples

Check out the sandbox directory.

Here is an example for the temporal network format tc.edge_changes.

import tacoma as tc
from tacoma.interactive import visualize

# define temporal network as a list of edge changes
temporal_network = tc.edge_changes()
temporal_network.N = 10
temporal_network.edges_initial = [ (0,1), (2,3), (1,7), (3,5), (1,9), (7,2) ]
temporal_network.t0 = 0.0
temporal_network.t = [ 0.8, 2.4 ]
temporal_network.tmax = 3.1
temporal_network.edges_in = [ 
                              [ (0, 5), (3, 6) ], 
                              [ (3, 7), (4, 9), (7, 8) ],
                            ]
temporal_network.edges_out = [ 
                                [ (0, 1) ],
                                [ (2, 3), (3, 6) ],
                             ]

visualize(temporal_network, frame_dt = 0.05)

visualization example

License

The whole software is published under the MIT software license. The documentation and all figures are copyrighted by Benjamin F. Maier. Ask for permission if you want to distribute parts.