API module

This module provides wrapper functions for the core functions provided in the C++-module _tacoma.

tacoma.api.aggregated_network(temporal_network)[source]

Measures the static network composed.

Parameters:temporal_network (_tacoma.edge_changes, _tacoma.edge_lists, _tacoma.edge_changes_with_histograms, or _tacoma.edge_lists_with_histograms) – An instance of a temporal network.
Returns:aggregated_network – Keys represent edges and values represent the aggregated time spent together (in units of time provided by the temporal network
Return type:dict where keys are pairs of ints and values are floats
tacoma.api.bin(temporal_network, dt=0.0, N_time_steps=0, verbose=False)[source]

Bins a temporal network for each dt (after each step, respectively, if N_time_steps was provided).

Parameters:
Returns:

An edge_lists instance with one edge list describing the network as a list of all edges that were present in the last time bin.

Return type:

_tacoma.edge_lists

tacoma.api.binned_social_trajectory(temporal_network, node, dt=0.0, N_time_steps=0, verbose=False)[source]

Computes the binned social trajectory of node node in temporal_network, i.e. the groups it was part of and pairs of times (t0, t1) when it was part of a certain group. In this case, binning makes it easier to, e.g. see the days where a group was active.

Parameters:
Returns:

A list, one entry for each dt. Each entry is a list of group ids.

Return type:

list of list of int

tacoma.api.concatenate(list_of_temporal_networks, verbose=False)[source]

Concatenates a list of either _tacoma.edge_changes or _tacoma.edge_lists to a single instance of _tacoma.edge_changes or _tacoma.edge_lists, respectively.

Parameters:
Returns:

Return type:

A single instance of the format provided in the lists.

tacoma.api.convert(temporal_network, verbose=False)[source]

Converts either an instance of _tacoma.edge_changes to an instance of _tacoma.edge_lists or vice versa.

Parameters:
Returns:

Return type:

An instance of the other format.

tacoma.api.convert_edge_trajectories(traj)[source]

Convert an instance of _tacoma.edge_trajectories to an instance of _tacoma.edge_changes. Note that there’s no method to convert to _tacoma.edge_lists directly.

Parameters:traj (_tacoma.edge_trajectories) – The temporal network which has to be converted.
Returns:temporal_network – The converted temporal network.
Return type:_tacoma.edge_changes
tacoma.api.convert_to_edge_trajectories(temporal_network, return_edge_similarities=False, verbose=False)[source]

Converts a temporal network to an instance of _tacoma.edge_trajectories.

Parameters:
Returns:

traj – The converted temporal network.

Return type:

_tacoma.edge_trajectories

tacoma.api.degree_distribution(temporal_network)[source]

Measures the time-averaged degree distribution.

Parameters:temporal_network (_tacoma.edge_changes, _tacoma.edge_lists, _tacoma.edge_changes_with_histograms, or _tacoma.edge_lists_with_histograms) – An instance of a temporal network.
Returns:P_k – A list of N entries where the k-th entry is the time-averaged probability of finding a node with degree k.
Return type:list of float
tacoma.api.edge_counts(temporal_network)[source]

Returns the number of edge events and total edge count (In this order: m_in, m_out, and m).

Parameters:temporal_network (_tacoma.edge_changes, _tacoma.edge_lists, _tacoma.edge_changes_with_histograms, or _tacoma.edge_lists_with_histograms) – A list of a temporal networks.
Returns:
  • list of int – Number of edges coming into the network at the corresponding times.
  • list of int – Number of edges leaving the network at the corresponding times.
  • list of int – Number of edges existent in the network at the corresponding times.
tacoma.api.get_edge_trajectories(temporal_network, return_edge_similarities=False, verbose=False)[source]

Computes a list of time intervals in which each edge existed and optionally the similarity between edges.

Parameters:
Returns:

  • trajectories (_tacoma.edge_trajectories.trajectories) – a list of edge_trajectory_entry objects, which contain the .time_pairs attributes, a list of time pairs (t0, t1) for time t0 <= t <= t1 in which the edge existed and .edge a pair of node integers.
  • similarities (_tacoma.edge_trajectories.edge_similarities) – a list of triples ( u, v, similarity ) where u and v refer to the edge indices in edge_trajectories.trajectories and similarity is the integrated time both edges were switched on while being connected to the same node.

tacoma.api.gillespie_SI(temporal_network, SI, is_static=False, verbose=False)[source]

Simulates an SI process on the provided temporal network using the Gillespie stochastic simulation algorithm.

Parameters:
Returns:

But the observables are saved in the _tacoma.SI object.

Return type:

None

tacoma.api.gillespie_SIR(temporal_network, SIR, is_static=False, verbose=False)[source]

Simulates an SIR process on the provided temporal network using the Gillespie stochastic simulation algorithm.

Parameters:
Returns:

But the observables are saved in the _tacoma.SIR object.

Return type:

None

tacoma.api.gillespie_SIRS(temporal_network, SIRS, is_static=False, verbose=False)[source]

Simulates an SIRS process on the provided temporal network using the Gillespie stochastic simulation algorithm.

Parameters:
Returns:

But the observables are saved in the _tacoma.SIRS object.

Return type:

None

tacoma.api.gillespie_SIS(temporal_network, SIS, is_static=False, verbose=False)[source]

Simulates an SIS process on the provided temporal network using the Gillespie stochastic simulation algorithm.

Parameters:
Returns:

But the observables are saved in the _tacoma.SIS object.

Return type:

None

tacoma.api.gillespie_epidemics(temporal_network_or_model, epidemic_object, is_static=False, reset_simulation_objects=True, verbose=False)[source]

Simulates an epidemic process on the provided temporal network using the Gillespie stochastic simulation algorithm.

Parameters:
Returns:

But the observables are saved in the _tacoma epidemic object.

Return type:

None

tacoma.api.gillespie_node_based_SIS(temporal_network, SIS, is_static=False, verbose=False)[source]

Simulates a node-based SIS process on the provided temporal network using the Gillespie stochastic simulation algorithm.

Parameters:
Returns:

But the observables are saved in the _tacoma.SIS object.

Return type:

None

tacoma.api.markov_epidemics(temporal_network_or_model, epidemic_object, max_dt, is_static=False, reset_simulation_objects=True, verbose=False)[source]

Integrates an epidemic markov process on the provided temporal network.

Parameters:
Returns:

But the observables are saved in the _tacoma epidemic Markov-object.

Return type:

None

tacoma.api.mean_degree(temporal_network)[source]

Computes the time dependent mean degree of the temporal network.

Parameters:temporal_network (_tacoma.edge_changes, _tacoma.edge_lists, _tacoma.edge_changes_with_histograms, or _tacoma.edge_lists_with_histograms) – A list of a temporal networks.
Returns:
  • numpy arrayt containing the time points.
  • numpy arrayk containing the mean degree at the corresponding times.
tacoma.api.measure_group_sizes_and_durations(temporal_network, ignore_size_histogram=False, verbose=False)[source]

Measures aggregated group size distribution, group size histogram for each time point, contact durations, inter-contact durations, durations of each group size, and the aggregated social network.

Parameters:
Returns:

The result of the measurements. Note that inter-contact durations is just durations of groups of size 1 and hence correspond to the first entry of _tacoma.group_sizes_and_durations.group_durations.

Return type:

_tacoma.group_sizes_and_durations

tacoma.api.sample(temporal_network, dt=0.0, N_time_steps=0, sample_aggregates=False, verbose=False)[source]

Samples a temporal network after each dt (after each step, respectively, if N_time_steps was provided).

Parameters:
  • temporal_network (_tacoma.edge_changes, _tacoma.edge_lists, _tacoma.edge_changes_with_histograms, or _tacoma.edge_lists_with_histograms) – An instance of a temporal network.
  • dt (float) – The demanded bin size. default : 0.0
  • N_time_steps (int) – Number of time bins (use either this or dt). default : 0
  • sample_aggregates (bool, optional) – If this is True, the following happens. If an edge is active during a time bin, it will appear in the final graph at the end of this time bin. It will then exist until the ende of the coming time bin. (This is different from the binning procedure). This does not seem to make very much sense so maybe just don’t use it. default : False
  • verbose (bool, optional) – Be chatty.
Returns:

An edge_lists instance with one edge list describing the network states after each discrete time step.

Return type:

_tacoma.edge_lists

tacoma.api.slice(temporal_network, new_t0, new_tmax, verbose=False)[source]

Get a slice of a temporal network for times new_t0 <= t < new_tmax.

Parameters:
Returns:

Sliced network (type depending on input type).

Return type:

_tacoma.edge_lists or _tacoma.edge_changes

tacoma.api.social_trajectory(temporal_network, node, verbose=False)[source]

Computes the social trajectory of node node in temporal_network, i.e. the groups it was part of and pairs of times (t0, t1) when it was part of a certain group.

Parameters:
Returns:

Return type:

list of _tacoma.social_trajectory_entry

tacoma.api.verify(temporal_network, verbose=False)[source]

Checks wether the temporal network is compliant with the demanded formats for analyses. Writes remarks on violations to stdout.

Parameters:
Returns:

Number of found errors.

Return type:

int