Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2024 Jul 4.
Published in final edited form as: Phys Rev Lett. 2024 Feb 16;132(7):077402. doi: 10.1103/PhysRevLett.132.077402

Compressing the Chronology of a Temporal Network with Graph Commutators

Andrea J Allen 1,2, Cristopher Moore 3, Laurent Hébert-Dufresne 1,4,*
PMCID: PMC11223189  NIHMSID: NIHMS1999338  PMID: 38427895

Abstract

Studies of dynamics on temporal networks often represent the network as a series of “snapshots,” static networks active for short durations of time. We argue that successive snapshots can be aggregated if doing so has little effect on the overlying dynamics. We propose a method to compress network chronologies by progressively combining pairs of snapshots whose matrix commutators have the smallest dynamical effect. We apply this method to epidemic modeling on real contact tracing data and find that it allows for significant compression while remaining faithful to the epidemic dynamics.

Introduction.—

High resolution temporal interaction data is now simple to obtain and widely available thanks to methods such as radio frequency identification [1] or Bluetooth signals [2]. Temporal interactions have rich dynamics in continuous time, yet we often want to combine intervals of temporal data into a series of simpler, static networks in order to compress the data, reduce analytical complexity, or streamline data collection efforts. For example, digital contact tracing protocols ping devices at fixed intervals to save energy and lighten data requirements. However, it is nontrivial to determine when and how to aggregate temporal data without losing critical information about the dynamics of the interactions.

Many methods currently exist to represent and analyze temporal networks [3], and to find patterns in network structure and dynamics. This includes algorithms for detecting temporal states [4], dynamical approaches for generating synthetic temporal network data [5,6], tools to identify community structure in time-varying networks [7], data-driven approaches to model dynamics on temporal networks by determining change points [8], and methods to represent key temporal features as static networks [9,10]. The dynamics of epidemic spread on temporal networks is well studied [1114], as are synchronization [1517] and control dynamics [18].

A continuing challenge is the interplay of dynamics on the network (changes in variables on nodes and edges) with dynamics of the network (where the topological structure changes over time). When the timescales of these two are well separated, we can take one of two limits. If the dynamics on the network are much faster, we can use a static limit where the network structure is essentially constant. When the dynamics on the network are much slower, referred to as the annealed limit, then the dynamical variables effectively experience the average of the network structure over time. Then we can aggregate many snapshots regardless of their chronological order. In between these two limits, neither type of dynamics can be neglected [19]. Then it is less clear how or if the history of the network’s structure can be compressed while remaining faithful to the dynamics on the network.

Here, we quantify the importance of chronology in a sequence of network snapshots by considering its effects on dynamics. Our goal is to compress unimportant structural changes while preserving changes that significantly affect the dynamical process. By compression, we mean a reduction in the number of snapshots used to represent a network’s history, rather than a minimization of the description length or memory needed for these snapshots [5]. This task has practical benefits, such as reducing the computational cost of simulation, and we consider it a fundamental scientific question: to what extent do we need to keep track of the chronological changes to a network’s structure in order to model dynamical processes on it?

We propose a method to do so by assessing the sensitivity of the dynamics to aggregating pairs of network snapshots. We take an epidemic spreading model as our main example, but we abstract the dynamics in a way that could represent other dynamical processes on networks (e.g., synchronization of coupled oscillators or cascading failures in power grids). Specifically, we formulate a pairwise error measure using matrix commutators that captures how aggregating snapshots affects the epidemic process, and we aggregate network snapshots as long as this error remains low. Using synthetic networks and real data, we find that this approach is successful at producing a compressed snapshot sequence that still mimics the dynamic behavior of the original sequence.

Analytical framework.—

We assume that we have some temporal network data consisting of a large number of snapshots of the network structure. (If we have a series of brief contacts between pairs of nodes in continuous time, this data would consist of a large series of mostly empty graphs.) We consider the dynamical error we would introduce by aggregating a given consecutive pair of snapshots into one. In an epidemic model, this error consists of creating paths that allow the contagion to progress backwards in time, as depicted in Fig. 1. If aggregating two snapshots would create many such chronology-violating paths, we should keep these snapshots separate and respect their chronological order.

FIG. 1.

FIG. 1.

Schema of our hierarchical aggregation. Given network snapshots, we compare the aggregate spreading dynamics of each adjacent pair of snapshots and combine the pair with the lowest induced error, continuing until we reach a desired number of snapshots.

In our epidemic example, a contagion spreads along edges connecting infectious nodes to their susceptible neighbors. We measure the effect of pairwise aggregation with a measure of error capturing the difference in the number of infected individuals, with and without aggregation over the duration of the snapshot pair. As we will see, we can approximate this error in terms of the commutator of two matrices, each of which linearizes the dynamics over the time interval of the snapshots.

Linearizing the SI model.—

Let At be the time-varying adjacency matrix of a network with N nodes. Let Pt be a vector of length N where Pit is the probability that a node i is infected at time t. A susceptible-infected-susceptible (SIS) model with infection rate β and recovery rate γ can be modeled by the following system of differential equations:

dPidt=β1PitAtPtiγPi, (1)

and the total number of infected individuals at time t is It=Pt where P=i=1NPi. In this paper we will focus on the SI model where γ=0. We then consider the early time linearization of Eq. (1) around P=0 (without losing much accuracy [20]), and thus have

dPdt=βAtPt. (2)

The solution to this equation involves a time-ordered exponential of At. In the case of a series of snapshots A1,,A, i.e., a sequence of static adjacency matrices which hold over time intervals of duration δt1,,δt, we have

Pt=i=1expβδtiAiP0. (3)

[This product is in reverse order since we treat Pt as a column vector and multiply on the left.] If all the Ai commute, this product reduces to expβiδtiAi, a single exponential of their weighted average. However, in general their noncommutative nature must be taken into account.

Aggregating snapshots.—

Say we have two consecutive snapshots, A and B, which are valid for time intervals t0A,t1A and t0B,t1B of duration δtA=t1At0A and δtB=t1Bt0B respectively, where t0B=t1A. In the linearized SI dynamics of Eq. (2), aggregating A and B in a single step is equivalent to replacing the time evolution operator expβδtBB expβδtAA with

expβδtA+δtBA,B¯,

where A,B¯ is the time-weighted average

A,B¯=δtAA+δtBBδtA+δtB. (4)

The effect of this aggregation can be quantified through the well-known Baker-Campbell-Hausdorff formula, which expresses the product expX expY as a single exponential expZ:

Z=X+Y+12X,Y+112X,X,YY,X,Y+ (5)

where X,Y=XYYX is the matrix commutator. Setting X=βδtBB and Y=βδtAA, we have

expβδtBBexpβδtAA=expZ,

where

Z=βδtA+δtBA,B¯+12β2δtAδtBB,A+Oβ3. (6)

Up to this point, we have used a known matrix formulation of dynamical processes on networks with or without temporal aggregation. This formulation was previously used to study the impact of temporal networks on the epidemic threshold [21,22] and to measure autocorrelations in temporal networks [22].

Here, the correction term proportional to B,A captures to leading order how aggregation introduces error into the dynamics. As illustrated in Fig. 1, aggregation creates chronology-violating paths whenever A and B do not commute. For example, if A includes the edge (1,2) and B includes the edge (2,3), then a disease could spread from node 1 to 3 in the chronology BA but not in AB. The commutator B,A counts paths allowed by BA and subtracts paths allowed by AB, compensating for the fact that the Taylor series of exp[(A;B)¯] contains terms proportional to both AB and BA.

Thus we use the correction term in Eq. (6) as a measure of the error induced by aggregation, or equivalently a measure of the sensitivity of the dynamics to the temporal ordering of A and B. Specifically, we use the operator norm of this term, i.e., its largest singular value, as an estimate of the error induced from the start to the end of the combined interval t0A,t1B:

ϵEND=12β2δtAδtB[B,A]op (7)

The operator norm bounds the effect of aggregation on any state Pt0A at the beginning of the interval. Note that ϵEND is small if β is small, i.e., if the epidemic dynamics is slow compared to the dynamics of the network structure. It is also small if either δtA or δtB is small, since in that case the effect of A or B is close to the identity.

We are interested in the effect of aggregation on the entire history of the system, not just the final state. We show an explanation of the problem in Fig. 2. Thus we also consider the error induced at the boundary t1A=t0B between the two intervals. To leading order we have

expβδtAAexpβδtAA,B¯=βδtAAA,B¯+Oβ2.

FIG. 2.

FIG. 2.

Top left: degree distributions for two snapshots. Top right: ordinary differential equation solutions of the SI dynamics with β=0.12, δt=5 on the temporal and aggregate versions of the snapshots with highlighted error terms. Bottom left: ODE solution difference in number of infected nodes under the temporal and aggregate regimes for varying values of βt by varying t=0,5. Bottom right: ranking of ξ1,2 for snapshots 1 and 2 for increasing values of βδt compared against the integrated area between solutions.

This term is in fact symmetric in A and B, since

βδtAAA,B¯=βδtAδtBδtA+δtBAB.

As before we bound the possible error induced at the midpoint as the operator norm of this term,

ϵMID=βδtAδtBδtA+δtBABop. (8)

We scale these terms by the cumulative duration of both snapshots—capturing the total effect that ϵMID and ϵEND have on the epidemic process (as visualized in the top right panel of Fig. 2)—which culminates in our error measure defined as

ξA,B=ϵEND+ϵMIDδtA+δtB. (9)

This measure includes both the error incurred by the overall difference between A and B, and the extent to which their chronological order matters. If our main goal is to compute the final state, we can place a smaller weight on ϵMID or focus entirely on ϵEND. Note that while ϵEND is second order in β and ϵMID is first order, either can dominate, e.g., if A and B have average degree d then A,Bop can grow as d2. This new quantification of compression error captures structure and dynamics, allowing us to introduce a dynamic-preserving algorithm for the compression of temporal networks.

Compression algorithm.—

Given a temporal network dataset as a sequence of M snapshots, we can use the framework to compress the snapshots into Mj snapshots via a greedy algorithm. First, the number of desired iterations j is set. For steps from 1 to j, (i) compute the error ξA,B from Eq. (9) for each ordered pair A, B of consecutive snapshots, (ii) identify the pair A*,B*=argminA,BξA,B to compress, (iii) replace A and B with their aggregate, A,B¯ over the union t0A,t1B of their time intervals. Alternately, we can compress until minA,BξA,B reaches some threshold.

This algorithm produces a hierarchical aggregation of snapshots as portrayed in Fig. 1. Periods where the network structure changes slowly or where snapshots commute become single snapshots with a long duration, while the periods with rapidly changing and noncommuting structures are preserved at a higher temporal resolution.

Results.—

Our algorithm produces aggregated snapshots that are able to better support the epidemic dynamics on the temporal network than the standard approach of evenly dividing time into windows of some fixed length and aggregating snapshots in each window. We call xtTEMP the SI dynamics of Eq. (1) integrated using the full temporal dataset and xtALG the dynamics integrated over the snapshots produced by our algorithm. As comparison methods, we use the common approach of evenly dividing the full time window into a certain number of snapshots of equal length [producing xtEVEN] and an information-theoretic method that optimally compresses the full sequence as a set of modes [producing xtMDL] [23]. This last method is a parameter-free approach designed to compress general multilayer networks using the minimum description length (MDL) principle. In particular, its level of compression and error cannot be tuned as our algorithm’s or the even division approach can be.

We measure the multiplicative error dALG as

dALG=xtALGxtTEMPxtTEMPdt (10)

and similarly for dEVEN and dMDL. We apply the algorithm to synthetic networks in Fig. 3, and to a dataset of four days and nights of contacts in a hospital [24] in Fig. 4, along with several other temporal contact network datasets [25].

FIG. 3.

FIG. 3.

Compression of a series of 50 synthetic network snapshots (detailed in appendix [20]), showing the SI dynamics with β=0.0017. Top: we use our algorithm to compress the network history to 6 snapshots of varying lengths, with boundaries shown by the orange dashed lines. We compare with the SI dynamics using even-width aggregation into 6 windows of fixed length (blue dashed lines). The snapshots produced by our algorithm give SI dynamics closer to that on the full temporal network (gray). Middle: normalized distance from the temporal curve over time for each solution, dALG for the algorithmic solution, and dEVEN for the even-width solution. Bottom: the vertical axis shows the shaded area from the middle panel as a function of number of aggregated snapshots, normalized by the error induced by aggregating the entire history into a single static network, measuring the error induced by aggregation as a fraction of the worst-case scenario. Generally, our algorithm results in almost ten times less error than even temporal split.

FIG. 4.

FIG. 4.

Application to empirical temporal network data. Top: error measure ξSt;St+1 computed for consecutive snapshot pairs at three different levels of preaggregation on a hospital contact network [24]. The hospital contact data contains contacts for approximately 9000 unique timestamps. We preaggregate by evenly coarse-graining the data to 4000, 1000, and 200 snapshots. Preaggregation of the data into small static snapshots does not affect the overall quality of our compression [20]. Middle: error of the SI process solutions, relative to the error induced by aggregating the entire history as a single static network (full error), as a function of resulting number of aggregated snapshots. The red star shows the error induced by the MDL optimal compression, which consists of 23 snapshots for this data. The vertical axis of the inset shows the ratio of compression achieved at a given error level by our algorithm versus even-width aggregation in orange markers, and versus MDL in a red star. For example, our algorithm can compress the data to 18 snapshots while maintaining lower error than 30 even snapshots, leading to a 30/18 (~1.7) compression ratio. Bottom: summary of the inset of the middle panel across other datasets [2628] showing the distribution of compression ratios. Our algorithm can be expected to further compress the number of snapshots by 50% to 100%. Importantly, it always outperforms MDL compression, although the two approaches can reach very similar outputs, for example on the conference dataset.

We show in the top panel of Fig. 4 how the sensitivity of certain temporal ranges is maintained over a large range of resolution, which allows for preaggregation of data to improve the speed of the algorithm. The error metric also allows us to identify the daily patterns of the contact data at a glance. Once integrated in the compression algorithm, the middle panel shows how we can aggregate over nights at the hospital, and capture the daily activity in one or two snapshots. As seen in Figs. 3 (bottom) and 4 (middle), our algorithm compresses more effectively than even-width time windows and the MDL method. In fact, for a given number of even-width aggregation steps, the algorithm can attain the same level of error after significantly more aggregation steps (~50%–200%). We call this additional aggregation the compression ratio and use it to summarize the results on other temporal data sets in Fig. 4 (bottom).

Discussion.—

The measure ξA,B of the error induced by aggregating adjacent snapshots, and our hierarchical compression algorithm based on it, offer at least four interesting applications.

First, the approach can directly provide bounds of accuracy when studying dynamics on temporal networks with tools developed for spreading on static networks. Second, our algorithm can help compress large sequences of temporal networks by aggregating consecutive pairs of networks to reach a desired level of simplification. Our algorithm could also be modified to aggregate snapshots until the expected error caused by this aggregation is smaller than some threshold. As shown in Fig. 4 using real temporal interaction data, this approach allowed us to consistently meet a certain level of error while decreasing the number of required network snapshots almost by half compared to aggregating into even-width windows.

Third, the error can be used to estimate the accuracy of data collection in the first place by testing how compressible the data might be. This could help focus data collection efforts by identifying places and times with fast temporal variations, as in the top panel of Fig. 4. Fourth, the error can be used on nontemporal data to compare the structure of any two networks that share some of the same nodes and support the same dynamics. At its core, our approach is a network comparison tool: How different are dynamics on two networks compared to dynamics on their average?

One important limitation is the greediness of our algorithm, as it can get stuck in suboptimal compression sequences. Future work should also explore how to predict the optimal stopping point of temporal compression. We hope that our work will inspire more tools to compress temporal network data while preserving the dynamical processes they support, which is an area rich in possible applications.

Code to support the preparation of this letter is available at [29]. The compression algorithm was implemented in Python and is available at [30].

Supplementary Material

Supplementary Material

Acknowledgments

A. J. A. and L. H. D. acknowledge support from the National Institutes of Health 1P20 GM125498-01 Centers of Biomedical Research Excellence Award and the National Science Foundation Grant No. DMS-1829826. C. M. is supported by NSF Grant BIGDATA-1838251.

References

  • [1].Cattuto Ciro, Van den Broeck Wouter, Barrat Alain, Colizza Vittoria, Pinton Jean-François, and Vespignani Alessandro, Dynamics of person-to-person interactions from distributed RFID sensor networks, PLoS One 5, e11596 (2010). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [2].Sapiezynski Piotr, Stopczynski Arkadiusz, Lassen David Dreyer, and Lehmann Sune, Interaction data from the copenhagen networks study, Sci. Data 6, 1 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [3].Holme Petter and Saramäki Jari, Temporal networks, Phys. Rep. 519, 97 (2012). [Google Scholar]
  • [4].Masuda Naoki and Holme Petter, Detecting sequences of system states in temporal networks, Sci. Rep. 9, 795 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [5].Peixoto Tiago P and Martin, Modelling sequences and temporal networks with dynamic community structures, Nat. Commun. 8, 582 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [6].Zhang Xiao, Moore Cristopher, and Newman Mark E. J., Random graph models for dynamic networks, Eur. Phys. J. B 90, 200 (2017). [Google Scholar]
  • [7].Ghasemian Amir, Zhang Pan, Clauset Aaron, Moore Cristopher, and Peel Leto, Detectability thresholds and optimal algorithms for community structure in dynamic networks, Phys. Rev. X 6, 031005 (2016). [Google Scholar]
  • [8].Peixoto Tiago P. and Gauvin Laetitia, Change points, memory and epidemic spreading in temporal networks, Sci. Rep. 8, 15511 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [9].Holme Petter, Epidemiologically optimal static networks from temporal network data, PLoS Comput. Biol. 9, e1003142 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [10].Scholtes Ingo, Wider Nicolas, and Garas Antonios, Higher-order aggregate networks in the analysis of temporal networks: Path structures and centralities, Eur. Phys. J. B 89, 61 (2016). [Google Scholar]
  • [11].Rocha Luis E. C., Liljeros Fredrik, and Holme Petter, Simulated epidemics in an empirical spatiotemporal network of 50,185 sexual contacts, PLoS Comput. Biol. 7, e1001109 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [12].Mathieu Génois Christian L. Vestergaard, Cattuto Ciro, and Barrat Alain, Compensating for population sampling in simulations of epidemic spread on temporal contact networks, Nat. Commun. 6, 8860 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [13].Ren Guangming and Wang Xingyuan, Epidemic spreading in time-varying community networks, Chaos 24, 023116 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [14].Valdano Eugenio, Ferreri Luca, Poletto Chiara, and Colizza Vittoria, Analytical computation of the epidemic threshold on temporal networks, Phys. Rev. X 5, 021005 (2015). [Google Scholar]
  • [15].Boccaletti Stefano, Hwang D-U, Chavez Mario, Amann Andreas, Kurths Jürgen, and Pecora Louis M., Synchronization in dynamical networks: Evolution along commutative graphs, Phys. Rev. E 74, 016102 (2006). [DOI] [PubMed] [Google Scholar]
  • [16].Stilwell Daniel J., Bollt Erik M., and Gray Roberson D, Sufficient conditions for fast switching synchronization in time-varying network topologies, SIAM J. Appl. Dyn. Syst. 5, 140 (2006). [Google Scholar]
  • [17].Zhang Yuanzhao and Strogatz Steven H., Designing temporal networks that synchronize under resource constraints, Nat. Commun. 12, 3273 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [18].Li Aming, Cornelius Sean P., Liu Y-Y, Wang Long, and Barabási A-L, The fundamental advantages of temporal networks, Science 358, 1042 (2017). [DOI] [PubMed] [Google Scholar]
  • [19].St-Onge Guillaume, Young Jean-Gabriel, Laurence Edward, Murphy Charles, and Dubé Louis J., Phase transition of the susceptible-infected-susceptible dynamics on time-varying configuration model networks, Phys. Rev. E 97, 022305 (2018). [DOI] [PubMed] [Google Scholar]
  • [20]. See Supplemental Material at http://link.aps.org/supplemental/10.1103/PhysRevLett.132.077402 for further detail on our derivation of the error measure, on our algorithmic implementation, and on our experiments. [Google Scholar]
  • [21].Speidel Leo, Klemm Konstantin, Eguíluz Víctor M, and Masuda Naoki, Temporal interactions facilitate endemicity in the susceptible-infected-susceptible epidemic model, New J. Phys. 18, 073013 (2016). [Google Scholar]
  • [22].Valdano Eugenio, Michele Re Fiorentin Chiara Poletto, and Colizza Vittoria, Epidemic threshold in continuous-time evolving networks, Phys. Rev. Lett. 120, 068302 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [23].Kirkley Alec, Rojas Alexis, Rosvall Martin, and Young Jean-Gabriel, Compressing network populations with modal networks reveal structural diversity, Commun. Phys. 6, 148 (2023). [Google Scholar]
  • [24].Vanhems Philippe, Barrat Alain, Cattuto Ciro, Pinton Jean-François, Khanafer Nagham, Corinne Régis Byeul-a Kim, Comte Brigitte, and Voirin Nicolas, Estimating potential infection transmission routes in hospital wards using wearable proximity sensors, PLoS One 8, e73970 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [25].Cattuto Ciro et al. , SocioPatterns is an interdisciplinary research collaboration formed in 2008 that adopts a data-driven methodology to study social dynamics and human activity, http://www.sociopatterns.org. [Google Scholar]
  • [26].Génois Mathieu and Barrat Alain, Can co-location be used as a proxy for face-to-face contacts?, EPJ Data Sci. 7, 11 (2018). [Google Scholar]
  • [27].Fournet Julie and Barrat Alain, Contact patterns among high school students, PLoS One 9, e107878 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [28].Isella Lorenzo, Juliette Stehlé Alain Barrat, Cattuto Ciro, Pinton Jean-François, and Van den Broeck Wouter, What’s in a crowd? Analysis of face-to-face behavioral networks, J. Theor. Biol. 271, 166 (2011). [DOI] [PubMed] [Google Scholar]
  • [29]. https://github.com/andrea-allen/network-compression. [Google Scholar]
  • [30].Allen A, Compressnets (2024), 10.5281/zenodo.10564812. [DOI] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supplementary Material

RESOURCES