Skip to main content

temporal_networks

PyPI version CI Documentation Status License: GPL v3

A Python package for analyzing temporal network evolution with automatic gap detection.

temporal_networks is designed for researchers who need to understand how network structure and properties change over time. Unlike general-purpose graph libraries such as networkx or igraph, it treats the temporal dimension as a first-class feature: it can ingest raw event streams directly into snapshots, measure how much structure persists between time steps, and characterise whether activations are bursty or regular — all with native support for irregular time series and missing data periods.

Compared to other temporal network packages such as teneto and dynetx, temporal_networks focuses specifically on gap-aware analysis and visualization, automatically detecting and correctly representing seasonal closures, maintenance windows, or crisis-driven interruptions rather than drawing misleading continuous lines across missing periods.

See the full documentation at temporal-networks.readthedocs.io.

Installation

pip install temporal_networks

Or install from source:

git clone https://github.com/cadrianas/temporal_networks
cd temporal_networks
pip install -e .

Quick Start

The example below goes from a raw event table to three kinds of temporal analysis in under 20 lines. The gap in May is detected automatically — no special configuration needed.

import random
import pandas as pd
import igraph as ig
from temporal_networks import (
    snapshots_from_events,
    snapshot_similarity,
    burstiness_coefficient,
)

# --- 1. Build snapshots from a raw event stream ---
events = pd.DataFrame({
    "time":   ["2024-01","2024-01","2024-02","2024-03",
               "2024-03","2024-04","2024-06","2024-06"],
    "source": ["A","B","A","B","A","A","B","A"],
    "target": ["B","C","C","C","C","B","C","C"],
})
# 2024-05 is absent from the data — gap is inferred automatically
graphs, labels = snapshots_from_events(
    events, time_col="time", source_col="source", target_col="target"
)
print(f"Snapshots: {labels}")
# ['2024-01', '2024-02', '2024-03', '2024-04', '2024-06']

# --- 2. How similar are consecutive snapshots? ---
sim = snapshot_similarity(graphs, graph_labels=labels, report_gaps=False)
print(sim[["Graph", "jaccard", "edge_persistence"]])
#      Graph  jaccard  edge_persistence
# 0  2024-02      0.0               0.0
# 1  2024-03      0.5               1.0
# 2  2024-04      0.0               0.0
# 3  2024-06      NaN               NaN   <- gap, not compared

# --- 3. Are edges bursty or regular? ---
bdf = burstiness_coefficient(
    graphs, graph_labels=labels, report_gaps=False
)
print(bdf[["entity", "n_events", "burstiness"]])
# Burstiness B: -1 = perfectly regular, 0 = Poisson-like, +1 = bursty

No files are written unless you pass save_path.

What's in the package

Data ingestion

Function Description
snapshots_from_events() Build igraph snapshots from a long-form event DataFrame
snapshots_from_edgelist() Load a timestamped CSV edge list into snapshots

Snapshot-level analysis

Function Description
network_properties() Structural metrics (density, diameter, clustering, …) per snapshot
calculate_centralities() 13 centrality measures tracked over time
communities_measures() 7 community detection algorithms with evolution tracking
vertex_properties() Single-node property trajectory
compute_edge_dynamics() Formation and dissolution counts between consecutive snapshots

Temporal structure

Function Description
snapshot_similarity() Jaccard, edge/node persistence, topological overlap between pairs
temporal_correlation_coefficient() Sequence-level average topological correlation
inter_event_times() Inter-event intervals (in inferred time units) per edge or node
burstiness_coefficient() Goh–Barabási B ∈ [−1, 1] per edge or node

Utilities

Function Description
detect_temporal_gaps() Standalone gap analysis and reporting

See the API reference for full parameter documentation.

Gap handling

All analysis functions accept a graph_labels list of date strings ("YYYY-MM", "YYYY-MM-DD", "YYYY-W##", "YYYY-Q#", or "YYYY"). The package infers the natural cadence from the label format and flags any skipped period as a gap. Gap-straddling results are reported as NaN rather than computed across missing data, and plots break the line at each gap so no false continuity is implied.

Tutorials

Two domain walkthroughs show the package on a complete dataset:

  • Face-to-face contacts in a school (docs) — a proximity study with an unobserved holiday break: ingestion from a contact log, community tracking across the break, and burstiness of ties
  • Agent-based epidemic modelling (docs) — contact data from an SIR agent-based model whose tracing programme is suspended for fifteen days: change-point detection around an intervention, and time-respecting paths that do not assume the unobserved period away

Reference walkthroughs covering the API surface:

  • Full integration walkthrough — one non-trivial temporal network (two communities, a broker snapshot, an anomaly, and a gap) threaded through every public function, with asserted invariants
  • New features walkthrough — ingestion, snapshot stability, and burstiness on a named-node sequence with a deliberate gap
  • Synthetic data walkthrough — gap-aware analysis comparing continuous and seasonal datasets

Reproducibility

To reproduce the synthetic results and gap-aware visualizations:

python examples/example_social_contacts.py
python examples/example_epidemic_abm.py
python examples/example_full_integration.py
python examples/example_specs_01_02_03.py
python examples/example_1_synthetic.py

example_social_contacts.py and example_epidemic_abm.py are seeded and self-checking: each asserts the substantive claims made in its documentation page (that the pair straddling the break is NaN, that the reshuffled students are detected in their new class, that an intervention is flagged as a change point while the resumption of data collection is not, and that allowing paths to cross a gap strictly increases reachability).

Every example is executed by the test suite (tests/test_examples.py), so a change that breaks one of these walkthroughs fails CI rather than going unnoticed. The two domain walkthroughs are additionally checked for reproducibility: each is run twice and its output compared, which is what keeps the numbers quoted in the documentation honest.

example_full_integration.py runs every public function on one shared synthetic dataset and asserts hand-checkable invariants (the gap pair is NaN, the known broker has the highest temporal betweenness, the injected anomaly is flagged). example_specs_01_02_03.py exercises the ingestion, stability, and burstiness modules on a small reproducible dataset and prints all results to stdout. example_1_synthetic.py runs the full suite of analyses on hub-and-spoke networks and saves comparative visualizations to plots/.

Citation

If you use temporal_networks in your research, please cite:

@software{ciupeanu_arino_temporal_networks,
  author    = {Ciupeanu, Adriana-Stefania and Arino, Julien},
  title     = {temporal\_networks: A Python package for analyzing
               temporal network evolution with automatic gap detection},
  year      = {2026},
  publisher = {GitHub},
  url       = {https://github.com/cadrianas/temporal_networks},
  note      = {Version 0.1.0}
}

Contributing

Contributions are welcome. See CONTRIBUTING.md for instructions on setting up a development environment and running the test suite locally.

License

GPL-3.0. See LICENSE for details.

Metadata

Release files for temporal-networks 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for temporal-networks 0.1.0
File Size Uploaded Provenance Actions
temporal_networks-0.1.0.tar.gz 67.2 kB With provenance Details for temporal_networks-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for temporal-networks 0.1.0
File Interpreter ABI Platform Actions
temporal_networks-0.1.0-py3-none-any.whl Python 3 none any Details for temporal_networks-0.1.0-py3-none-any.whl

Total release size: 149.4 kB

Release files / temporal_networks-0.1.0.tar.gz

Download URL temporal_networks-0.1.0.tar.gz
Size 67.2 kB
Tags Source
SHA-256 checksum
How to use checksums
29d9d7e4aac81f2e21773e6823f09229e8e79817dd77f5c3ee0bab762cc8cbda
BLAKE2b-256 checksum
How to use checksums
e4b6eafc94ce3b9c2bc33436e0d9b8d46c28ea0977d7a5dcff063930b576e6e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / temporal_networks-0.1.0-py3-none-any.whl

Download URL temporal_networks-0.1.0-py3-none-any.whl
Size 82.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a92547da233af2c9d0cc3268b230d4dcd176a313ed692ef45a69f30a776a0b48
BLAKE2b-256 checksum
How to use checksums
354c35a2f698057703888602448153cb726fb847c52bf5312b69119f6ab9e224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for temporal-networks 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for temporal_networks-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page