Generating fine-grained surrogate temporal networks

Temporal networks are essential for modeling and understanding systems whose behavior varies in time, from social interactions to biological systems. Often, however, real-world data are prohibitively expensive to collect in a large scale or unshareable due to privacy concerns. A promising way to bypass the problem consists in generating arbitrarily large and anonymized synthetic graphs with the properties of real-world networks, namely `surrogate networks'. Until now, the generation of realistic surrogate temporal networks has remained an open problem, due to the difficulty of capturing both the temporal and topological properties of the input network, as well as their correlations, in a scalable model. Here, we propose a novel and simple method for generating surrogate temporal networks. Our method decomposes the input network into star-like structures evolving in time. Then those structures are used as building blocks to generate a surrogate temporal network. Our model vastly outperforms current methods across multiple examples of temporal networks in terms of both topological and dynamical similarity. We further show that beyond generating realistic interaction patterns, our method is able to capture intrinsic temporal periodicity of temporal networks, all with an execution time lower than competing methods by multiple orders of magnitude. The simplicity of our algorithm makes it easily interpretable, extendable and algorithmically scalable.


Introduction
In the past decade, temporal networks have driven breakthroughs in real world systems across biology, communications, social interactions, and mobility. One of the main advantages of temporal networks resides in their ability to capture complex dynamics such as, for instance, diffusion and contagion. [1][2][3][4][5][6][7][8][9][10] Here we assume that a temporal network is represented in discrete time with each time step corresponding to a static graph, also referred to as a 'layer' of the network. In order to model realistic dynamics, it is often necessary to employ large temporal networks, including a large number of nodes and long time intervals, i.e. many temporal layers . [11][12][13] Many state-of-the-art temporal datasets, however, are limited both in the number of nodes and in the number of temporal layers. 6,[14][15][16][17] When the available data are insufficient -e.g. to simulate long-term effects of epidemics -datasets are extended by simply repeating the same temporal sequence multiple times, a procedure which is known to result in biases. 15 An appealing solution to the problem of insufficient data is to use surrogate temporal networks. 18 Surrogate temporal networks are synthetic datasets which mimic the real-world temporal patterns relevant for a desired use-case. Real networks are indeed known to be characterized by typical patterns of interactions, different in different domains (social, biological, infrastructural, etc.), which can be often recognized and delineated 19,20 and the role of surrogate networks is to try to reproduce them. The surrogates can be designed to involve the desired number of nodes and number of temporal layers, where the actual dynamics are known through smaller studies or via available small datasets.
Moreover, in the case of privacy sensitive data, such as fine-grained records of social interactions, 21 surrogate data can be generated so as to be freely shareable. Over the past years, a large number of successful algorithms for static network generation have been proposed; 22,23 however, extending these models to the dynamic regime has proven prohibitively difficult, due to greatly increased complexity introduced by the temporal dimension.
Indeed, it has become clear that temporal networks are characterized by a highly nontrivial interplay between the instantaneous network topology at a given time (adjacency, degree distribution, clustering, etc.) and the temporal activation of nodes and linkshow each connection changes over time (duration of interactions, patterns by which new links appear and old ones disappear, etc.). From the perspective of an individual node, these two dimensions imply that models must take into account (i) time, i.e. the history of what has occurred in the preceding timesteps and (ii) instantaneous local topology, i.e. the current activation of the neighboring nodes. The scientific literature is full of studies focusing on the spatial dimension but unable to take into account possible temporal correlations, [24][25][26][27][28][29] or -alternatively -works dedicated to model the behavior of individual nodes in time (for example activity driven models 7,30 ) which do not aim to reproduce realistic network topologies. 31 There exist models for link prediction that try to combine temporal and topological dimensions by using small local temporal patterns 32 or building over a backbone of significant links. 18 However, there is currently a dearth of models for generating surrogate networks from scratch that are able to take into account the two dimensions simultaneously. The few works, that do this rely on temporal motifs, like Dymond 33 and STM, 34 or on deep learning like TagGen. 35 These three models described in detail in Methods, represent the state-of-the-art. All these models however suffer from some limitations and some of the characteristics of the original networks are not always well reproduced by the surrogate networks.
In this work we propose an alternative method that is particularly efficient in reproducing temporal networks characterized by high temporal resolution and we test it with a wide range of topological and dynamical measures, comparing it with the above cited approaches. The method that we propose is based on temporal motifs that are defined with an 'egocentric' perspective. Conceptually, we collect the local interactions of each node for a small number of time steps in a real network, the egocentric temporal neighborhood, and we consider them as representative of that network of interactions. We then use them as building blocks to generate a new synthetic network.
A major advantage of the egocentric perspective (that ignores connections among neighbors of an ego node) is that it allows us to linearize the concept of node neighborhood sidestepping the subgraph isomorphism problem, 36 that often represents a bottleneck for the algorithms based on motifs . This makes the generation process fast and scalable both in terms of the number of nodes and the number of temporal snapshots. Speed turns out to be a fundamental feature, because the other existing methods rely on algorithms of considerably higher complexity that prevent those methods from scaling to even moderately-sized networks.
We test the method, named Egocentric Temporal Neighborhood Generator (ETN-gen), on a range of different temporal networks. In our testing we mainly use social interactions datasets because of richness and availability of these datasets, but the method is general and can be used to generate any kind of graph. Our results show that the surrogate networks that we generate reflect many of the original networks properties with a high degree of accuracy, not just in terms of specific nodes features, as one might anticipate from the local generating mechanism, but with respect to general features, such as the number of interactions, the number of interacting individuals in time and density of their connections. We notice that the characteristics that are better preserved coincide with the ones that depend on time and describe the temporal behavior of the specific nodes, while global features that deal with the spatial organization of the network and which can be observed for instance when collapsing the temporal layers (like the existence of communities) are more difficult to reproduce with this method.
In general, this work places itself as a first step towards a deeper understanding of time-varying interaction processes. It allows us in particular to set the spatio-temporal scale of the minimal fundamental knowledge that is necessary to capture many of the intrinsic characteristics that we aim to reproduce in a temporal network. The possibility to generate surrogate networks that resemble an original one serves as a test to demonstrate the method efficiency.

The neighborhood generation process
e e e e e e Figure 1 shows a graphical representation of the generation process for a small temporal network with three timesteps (see Methods for details).
Our generative algorithm uses as building block the Egocentric Temporal Neighborhood 40 of a node (E {t−k,...,t} i for node i), which represents the neighborhood of a node over a (short) temporal span k. For the sake of compactness, we will refer to the Egocentric Temporal Neighborhood as ETN or simply neighborhood in the rest of the manuscript.
Panel A of Figure 1 shows the neighborhood of a specific node, denoted as e, for a tem- Third (panel C), we build the surrogate network layer after layer. Given the first k layers, we generate the subsequent one by sampling future interactions for each node from the local probability distribution described above, thus generating a provisional temporal extension of each node. Notice that since local probability distributions ignore node identities, future interactions can only involve previously existing neighbors or novel (still unknown) nodes (question mark in panel C). All the interactions extracted for each node e are represented as directed links from e to its desired neighbors (including "stubs", representing links-to-be to unknown nodes). We thus obtain a provisional directed temporal layer of the network.
Last (panel D), this provisional layer is finalized by combining provisional temporal extensions of all nodes, resolving conflicts and dangling links so as to preserve as much as possible each node's desired neighborhood. We consider a connection from node i to node j in the provisional layer a 'request' of i to be connected to j. If this request is reciprocal the link is validated and added to the new temporal layer (second step in panel D).
All remaining one-directional links are validated with probability α = 1/2 (third step), to preserve the overall number of connections (an i − j connection can be requested by i or by j). Finally, stubs are pairwise matched up at random (last step in panel D). The procedure is repeated as many times as the desired length of the final temporal graph, always considering the last k timestamps as seeds to generate an additional one.
With the basic mechanisms in place, we take a step back and explain how to initialize the process, i.e. how to obtain the first k layers of the graph. The graph at the first timestamp is generated using a configuration model 41, 42 reproducing the degree distribution of the first layer of the original graph. The following layers up to k are generated by applying the procedure in Figure 1 to the first layer with k ′ = 1, to the first two layers with k ′ = 2 and so on until k ′ = k.
Temporal networks are often characterized by an intrinsic periodicity. 1 This can be captured in our generation process by collecting multiple local probability distributions from the original graph, associated for instance to different days of the week or times of the day. In the experiments in this paper we use distinct week/weekends or daily local probability distributions, depending on the length and variability of the input network.
The recursive procedure poses no limit to the temporal extension of the network, al-lowing to generate as many temporal layers as desired, even more than those existing in the original network. Plus, the number of nodes too can be set independently of the original network size (Section 2.5).
Above, we have described the simplest possible strategy for extending a layer into the future, but note that all random choices in the link validation process could become preferential choices in order to optimize a specific characteristic of the final network (see Section 2.3).

Model evaluation
We now evaluate the quality of the generated networks based on interaction statistics by comparing the networks to empirical data as well as networks generated by a suite of state-of-the-art temporal network generation methods described below. We evaluate performance in terms of individual layer topology as well as temporal behavior.
The state-of-the-art methods we consider are: Dymond, 33 a model which uses the distribution of 3-nodes structures in the original graph (triads with one, two or three con- and compared only to TagGen due to computational complexity of the other methods. Figure 2 reports the total number of interactions for each temporal snapshot (left) and the average number of nodes (right) in the original network, ETN-gen and the three state-of-the-art methods. The first clear finding from this figure is that ETN-gen (orange curves) results in time-series that are remarkably similar to those appearing in the original datasets (black curves). This is true, not just in terms of generating a number of interactions which is of the same order of magnitude as the original data (notice that different datasets have different scales on the y-axis), but also in terms of temporal patterns which are preserved with considerable accuracy, including daily and weekly periodicity.
This result should not come as a surprise, as it is a direct consequence of our network generation procedure. The local probabilistic models store the probability distributions of the neighborhoods appearing in the original graph and this indirectly contains the key information about how nodes degree evolves in time. Further, our seed-network has the same degree distribution as the original graph, which allows us to statistically preserve the overall average number of interactions of the original graph. Moreover, we manually input periodicity via different local probabilistic models for different times and days of the week. We highlight, however, that while using only a single local probabilistic model would remove our ability to model periodic changes in graph over time, we would still be able to model the average number of interactions, as these are automatically reproduced by the rest of the algorithm. A detailed analysis is reported in the SI (Section S9).
From the comparison with the other methods we conclude that ETN-gen is the only method able to preserve the number of nodes, the order of magnitude of the amount of interactions and the periodicity of the original network. The curves for the original network and ETN-gen are also reported in Figure S1 in SI for larger datasets to which the other methods cannot be applied due to computational constraints.

Topological similarity evaluation
Having studied the temporal development, we now turn to structural similarity between the surrogate data and the original networks. We consider seventeen metrics for structural similarity, divided between those that depend on time, namely: number  of connected components, 43 density, 33 number of interacting individuals, 11 new conversations, 11 hour S-metric, 44 hour modularity, 45, 46 duration of contacts, 11 closeness, 43 hour betweenness (weighted and unweighted), 43 hour clustering, 47, 48 hour assortativity, 49 hour average shortest path length; 1 and those that are measured on the aggregated network (i.e. collapsing all the temporal layers in one weighted network), which are: closeness, 43 betweenness (weighted and unweighted), 43 and edge strength. 11 All the measures are collected as distributions, the temporal ones measured on each singular temporal layer or on slots of one hour (those whose names start with "Hour"), and the aggregated ones as distributions over the edges or the nodes. See SI for the definition of all measures.
To compare distributions we rely, inspired by Zeno et al., 33 on the Kolmogorov-Smirnov distance 50 to contrast generated and original graphs. In the SI, we also consider alternative distance measures, namely the Jensen-Shannon divergence, 51 the Kullback-Leibler divergence, 52 and the Earth mover's distance, 53 obtaining similar results (see Section S12 in SI). Distances between distributions are reported in Figures 3 and 4, where we compare graphs obtained with ETN-gen with those from the three alternative approaches. The networks generated with ETN-gen (orange bars) show a high similarity to the original networks for many of the measures and also a high stability (small errorbars). The measures for which ETN-gen performs best are those that, together with the number of interactions (see Figure 2), are preserved by construction: the density and the number of interacting individuals in time. Here, the similarity originates from the neighborhood probability distributions, which ensure that from a statistical viewpoint, the surrogate network has the same number of interactions and the same number of individuals involved in an interaction. The same holds for the number of times that a new link appears, as these statistics are also stored in the neighborhood probability distributions. Another characteristic that is well captured by the egocentric temporal neighborhoods is the hub-like structure that we can find in each static layer, which is measured by the S-metric. 44 Going beyond these 'trivial' consequences of the mechanics of the generating mechanisms, the method does well at preserving the number of connected components. Indeed, the inset shows how the ETN-gen networks exhibit a distribution of the number of connected components that is similar to the original one, while TagGen shows a rather larger distribution difference and the other methods generate substantially fewer (Dymond) or more (STM) connected components. This is a consequence of the fine-grained temporal information that ETN-gen uses to generate the networks. For the same reason, the hour modularity of ETN-gen networks is always better or comparable with that of the other generated networks.
The distribution of durations is instead not very well reproduced, but it is not bad with respect to the other methods. In fact, considering a k-steps memory allows interactions to have a continuity in time, differently from the case of independent layers.
We also test three different centrality measures. Since centrality is a quantity that characterizes each node at each time, we focus first on the temporal distributions, by reporting for each temporal slot lasting one hour the nodes average (see Figure 3). Then we consider the spatial distribution, reporting the centrality of each node computed on the time aggregated network (see Figure 4). We observe that when we consider the temporal distribution we obtain a higher similarity to the original networks, confirming the insight that ETN-gen is more valid in reproducing fine-grained time features, while it results more limited in reproducing the global spatial organization of the networks.
Another interesting property is the distribution of edge strengths in the projected graph (see Figure 4). Edge strength is simply the number of times that each edge has appeared over the duration of the graph. Here, we would not necessarily expect ETN-gen to do well as the method will tend to create networks with quite homogeneous distributions of strength. This is because it can only rely on a memory of order k for edge repetitions, and does not have a long-term memory. Hence all the heterogeneous behaviors that we can find for instance in social datasets, where individuals tend to establish relationships with specific nodes and have repeated (but not necessarily consecutive) interactions with them, are not preserved by ETN-gen. Nevertheless, we find that for the considered datasets ETN-gen remains competitive with the other methods.
If edge strength is partially affected by the absence of long memory, the most important limitations of the egocentric perspective are highlighted by clustering, degree assortativity and average shortest path length, which are related to second-order interactions (see Figure 3). This is the cost we pay for having a computationally efficient model applicable to arbitrary networks. Notice that while this is a problem in theory, it seems not to affect the workplace dataset, which is a substantially sparser network with low clustering and short paths.
In general from the topological analysis we observe that the features that are more preserved are the time-dependent ones (at least those that do not depend on second-order interactions), while the method is more limited in reproducing the time-aggregated measures. This is valid for both local and global features. An additional analysis on meso-scale structures is reported in Section S11 of SI. We observe that small static motifs are well preserved by ETN-gen (Section S11.2) but not the network communities (if present in the original graph). This is a common limitation involving the other generation methods, too.

Dynamical similarity evaluation
Having tested our method from the structural point of view, we now test the usefulness of the surrogate networks in terms of dynamical processes unfolding upon them. We study two dynamical models: random walk and a spreading model. Our method is represented in orange, while the solid black line shows the stability (i.e. the same simulation on the original network).

Random walk
We simulate a temporal random walk 11, 54 on the original and generated networks. We use the standard definition of random walk extended to temporal networks: a random walker starts from a randomly chosen node at generic time t and chooses uniformly at random one of its neighbors, moving there. Then the second step will take place on the following layer of the temporal network, so the walker will randomly choose between its neighbors at time t + 1, and so on, assuming that at each time corresponds one and only one jump.
We compute two metrics: coverage and mean first passage time (MFPT), and compare distributions over different realizations between the input and the generated temporal network using again the Kolmogorov-Smirnov distance (see SI for the definition of the metrics). We consider three different starting points: t = 0, t = len(G)/2 (in the middle point of the temporal extension of the graph), and the time corresponding to the first peak of connections (when the number of connections reaches a maximum).
In Figure 5 we report the Kolmogorov-Smirnov distance for coverage and MFPT. The horizontal dashed line shows the stability of each measure on the original network. The black line is obtained comparing different performances (average over 1000 simulations of random walk for coverage, and 5 times each couple of nodes for mean first passage time) by means of the Kolmogorov-Smirnov distance. It is worth noting that the stability is different from zero, due to inherent variations within the dynamic process.
We observe that the dynamics on the ETN-gen networks are similar to the ones on the original networks in terms of mean first passage time, while in terms of coverage performance they depend on the datasets and the starting point but they always results competitive with the ones obtained with the alternative methods. In Section S4 we also report the evolution in time of the number of newly visited nodes.
In general we can say that the random walk process on the ETN-gen's surrogate networks is quite similar to the random walk on the original graph.

Spreading model
We simulate a Susceptible-Infectious-Recovered (SIR) model, 55 with three possible values for the probability of disease transmission (λ ∈ {0.25, 0.13, 0.01}), and the recovery rate fixed at µ = 0.055. In each simulation the infection starts at time t START by assigning to one random node (selected among the connected ones at that time) the status of infected. This initial node will infect its neighbors with probability λ and recover with probability µ. In the next time step we consider the following temporal layer of the net- work and again the infected nodes can infect their new neighbors or they can recover.
We repeat the procedure until the end of the temporal layers or until all the infected nodes have recovered. Again, we consider the three different starting points described above also for the dynamics. We compute the reproduction value R 0 (see SI for the definition). Each experiment was repeated 100 times and the distribution of R 0 obtained on the original network is, again, compared with those obtained on synthetic networks by means of the Kolmogorov-Smirnov distance. Results are shown in Figure 6, where again a horizontal black line shows the stability of each measure on the original network (computed averaging over 100 simulations). We observe that the results obtained with ETN-gen are highly similar to those of the original graph and show a large degree of stability with respect to this similarity. In Section S4 we also report the evolution in time of the number of infected nodes.

Dataset expansion and extension
In the previous sections we have argued that ETN-gen creates realistic surrogate temporal networks that mimic many aspects of real social dynamics (both in terms of structure and in reproducing dynamical systems).
Now we ask the question: How can this tool be useful in practice? A relevant application is represented by the possibility of enlarging a given temporal dataset, both in time and in size. It is indeed common that a specific analysis, in order to yield reliable results, requires a larger population or a longer time than those characterizing collected real data. In those cases we deal with the long-standing problem of data augmentation, for which we now argue that ETN-gen represents a promising solution. In the following we show how our method can be used for augmenting a temporal dataset, by adding temporal layers (temporal extension), but also by increasing the size of the network in terms of number of nodes (size expansion).

Temporal extension
The procedure, as explained in the previous sections, implies calculating the neighbor- week networks are generated, and they are eventually "tested" comparing them with the two-weeks-long real dataset. Results show how the generated networks accurately recreate the original behavior beyond the timespan that was used to estimate the local probability distributions.

Size expansion
Here we explore the fidelity of surrogate networks with an increased number of nodes.
As discussed above, it is possible to increase the size beyond that of the original network within the ETN-gen framework because the number of nodes is simply a parameter to set for the method. That said, however, the concept of size expansion requires more attention than time extension. Because, as we change the number of nodes in a network we should also consider how the density of the graph and the mean degree should change accordingly.
In the following we describe an experiment of data augmentation, assuming that we only have access to incomplete data. Incomplete data are obtained by randomly removing part of the nodes from the original network. We use the high school dataset which, with its 126 nodes, is the largest among our datasets, and we consider two reduced versions, with 30% and 70% of the nodes respectively. When removing part of the nodes from a network, we naturally remove also part of the links (all those which were before connecting the eliminated nodes to the remaining ones), we hence reduce the mean degree. We should consider that an incomplete dataset has in general a reduced mean degree with respect to the real-world network, and that when we try to reconstruct the

Temporal extension and size expansion
We can also combine the two techniques above to simultaneously increase the number of nodes and the temporal snapshots. The results are shown in bottom panel of Figure 7 for the high school network, where the synthetic graph has been obtained by only using 50% of the nodes and the first two days of the original dataset (from the beginning to the vertical line), see the black dashed curve. Also in this case, our method is able to extend an input graph in both the temporal and the node size dimensions with remarkable accuracy.

Discussion
In this manuscript we have proposed a model to generate surrogate temporal networks, i.e. synthetic networks that realistically capture many properties of real-world datasets, only making use of the information contained in egocentric temporal neighborhoods. Specifically, we generate temporal networks which accurately reproduce structural characteristics like density, number of interacting individuals, number of connected components, and the possible presence of hubs. We observe that in both topological and dynamical tests, the networks generated by this model are generally closer to the original graph than those generated by different literature models. Moreover, this approach is able to generate temporal networks that have different sizes than the original one. This property can be used to increase the number of nodes and extend the network in time, providing a powerful tool for data augmentation. These results suggest that egocentric temporal neighborhoods, that we use as building blocks, contain fundamental information about the real networks they are extracted from.
By using ETN-gen surrogate networks it is possible to overcome privacy issues, too. We did not explicitly prove that such surrogate networks are impossible to de-anonymize, but we are rather confident in the privacy-preserving properties of the method. In fact, the interactions of one node in the surrogate are designed based on the probability distribution of ETN prolongation, that is in its turn constructed based on the interactions of all the nodes in the original graph (remembering that the identity of nodes are not stored). Therefore there is not a match node-to-node between surrogate and original graph. More precisely, the set of interactions of one node in the original graph is distributed among multiple nodes in the surrogate graph. We hence find it unlikely that real nodes can be reconstructed and identified observing the surrogate network. However, this will be matter of future investigations.
The other side of the coin is that this simplicity does not capture certain topological features. This is the main limitation of the model. For instance, disregarding second-order interactions translates to a reduced ability to preserving clustering, degree correlations and average shortest path length. This is the price to pay to achieve scalability, sidestepping the graph isomorphism problem in mining egocentric temporal neighborhoods.
Just getting rid of this simplifying assumption would imply a substantial blow-up in computational complexity (as suggested by the runtime comparisons with alternative approaches reported in Table S1) and, as a consequence, a significant reduction in the timespan of the temporal neighborhood that could be dealt with. Trading second order interactions for longer temporal neighborhoods allows us to reproduce most of the relevant features of temporal networks while maintaining computational efficiency. Nevertheless, further research is needed to explore alternative trade-offs in the expressivityefficiency scale. Another limitation of the proposed approach is the absence of longterm memory, which implies that the model cannot capture long-term patterns of interaction (like e.g. daily or weekly recurrences). These features are instead well captured by more theoretical models of network generation that include aging, 56, 57 edge reinforcement, 58,59 or in general some mechanism for memory such that contact duration and inter-event times are heterogeneous and depend on the past interactions. 60,61 Memory could also be used to generate a synthetic temporal network that is organized in communities. 62,63 This is a characteristic often occurring in social networks (particularly evident in schools), and it cannot be captured by small local subnetworks like egocentric temporal neighborhoods. However, long-term memory appears in literature only in theoretical models for temporal network generation, for which the goal is to obtain realistic networks by recovering some particular characteristics of the observed dynamics in real networks, but usually do not aim at reconstructing specific real networks or environments. Indeed, the alternative methods we evaluated in this manuscript also fail to account for long-term memory. A model which instead is built to obtain surrogate networks with an alternative approach is the one proposed by Presigny et al. 18

Methods
Data description and processing. The three temporal networks studied in the main body of this work represent face-to-face human interactions collected by the SocioPatterns project 1 : • Hospital. 37 The dataset has been collected in the geriatric ward of a university • Workplace. 38 The dataset has been collected in 2013 at the Institut National de Where F 1 (x) and F 2 (x) are the empirical cumulative distributions of the two sets.
While originally conceived for hypothesis testing, the KS statistic has often been used to measure the distance between empirical cumulative distributions. 33, [65][66][67][68][69] We follow this common practise in this manuscript.
Neighbourhood generation process: parameters. The gap between two consecutive temporal snapshots has been set to 5 minutes for face-to-face interaction networks and 10 minutes for SMS and phone call networks (in SI). The time horizon k defining the egocentric temporal neighbourhood has been set to k = 2 in all experiments, which is the minimal horizon that preserves some temporal correlation. In section S8 we motivate our decision in using k = 2 but also show the results for k = 3 . Local probability models have a granularity of 1 hour and a periodicity of 1 day (i.e. between 8 and 9 am in each day we use the same probability model, and the same holds for all 1 hour slots in the day), for all networks but the ones including weekends, namely Workplace and High school 2, for which the periodicity is set to 1 week. Size expansion: preserving interaction density. The seed graphs for the size expansion experiment are generated by artificially reducing the original dataset (so that the original graph can be used as ground-truth). In this reduction process, whenever a node is dropped all its connections are dropped too. As a consequence, the resulting seed graph has a reduced mean degree with respect to the original one, and the expanded graph generated from it would inherit this reduced mean degree. This problem can be avoided by adjusting the α parameter of the generation process (the probability to confirm the unidirectional links in each provisional layer, set to 1/2 by default). In particular, we would need to set α = 1 − 1 2L L , whereL is the average number of links in the seed graph and L the desired number of links in the generated graph. However, L is unknown and needs to be estimated. Something that we know, and that we want in this case to preserve, is the density, defined as d =ˆL N·(N−1)/2 i.e. the fraction between the number of links in the seed graph and all possible links (N is the number of nodes in the seed graph). If we assume a linear growth with respect to the number of all possible edges in the network, we also have: d = L N·(N−1)/2 , with N as the number of nodes of the generated graph (that we can choose). Combining these two equations we obtain an estimate for L, from which we obtain: Hence, when we consider a seed with only 30% of the nodes of the high school dataset (so N = 126 andN = 38) we should use α = 0.96 to reproduce the same density. While if we start with 50% and 70% of the nodes (i.e.N = 63 andN = 88) in the seed we should use respectively α = 0.88 and 0.76.
Alternatives approaches for generating networks. Dymond 33 builds a temporal network considering (i) the dynamics of temporal motifs in the graph and (ii) the roles nodes play in motifs (e.g. in a wedge -two links connecting three nodes -one node plays the hub, while the remaining two act as spokes). The method has no parameters to be set. Structural Temporal Modeling (STM) 34 extracts counts for a predefined library of (non-egocentric) temporal motifs from the original network, and turns them into generation probabilities from which to create the temporal network. In particular, we use the parameterized version of STM and we set the parameter α = 0.6 as recommended by 34 . TagGen 35 is a neural-network based approach that extracts temporal random walks from the original graph and feeds them to an assembling module for generating temporal networks. TagGen has been trained with the parameters used in the original paper, namely 30 epochs with a batch size of 64 and stochastic gradient descent with a learning rate of 0.001.

Code and data availability
The data used to support this study are publicly available at the following links.

S1 Topological and dynamical metrics details
In the main text we use seventeen different topological metrics and three dynamical metrics to compare the original graphs with the synthetic ones. The topological metrics can be divided into thirteen time-dependent metrics, which (except for contact durations) are computed for each temporal layer as it was a static network, and for which we report distributions over temporal layers (or over slots of one hour length, where indicated): • Density. The ratio of edges in the graph versus the number of edges if it was a complete graph. 33 • Interacting individuals. The number of individuals that are interacting. 11 • New conversations. The number of conversations starting at each specific timestamp. 11 • Hour S-metric. A measure of the extent to which a graph has a hub-like core, maximized when high-degree nodes are connected to other high-degree nodes. 44 This is not computed on singular layers but on the networks resulting from aggregating slots corresponding to 1 hour.
• Hour clustering coefficient. The ratio of the number of closed triplets to the total number of open and closed triplets. 47,48 This is computed on the networks resulting from aggregating slots of 1 hour.
• Hour assortativity. The degree-degree correlation of nodes that are connected. 49 This is computed on the networks resulting from aggregating slots of 1 hour. • Hour modularity. First a partition of the 1-hour-aggregated network is obtained using the Louvain algorithm 45 and then the modularity is computed according to Clauset et al. 46 • Hour betweenness centrality (weighted and unweighted). Nodes centrality averaged over all nodes of the one-hour-long-aggregated networks. 70 • Hour closeness centrality. Nodes centrality averaged over all nodes of the onehour-long-aggregated networks. 71 • Number of connected components. Number of subnetworks each snapshot is divided into.
• Duration of contacts. The mean duration (in timestamps) of interactions between each couple of nodes. 11 And four time-aggregated metrics (computed over the aggregate networks) : • Betweenness centrality (weighted and unweighted). Centrality of each node in the aggregated. 70 • Closeness centrality. Centrality of each node in the aggregated. 71 • Edge strength. Weight of each edge in the aggregated. 11 The dynamical metrics are obtained starting from two dynamical processes, a random walk and a spreading process. For random walk we use: • Coverage. The number of (distinct) visited nodes starting from a random node at an initial timestamp. 11 The simulation is repeated 1000 times using a random initial node and the initial time is set equal to the first timestamp.
• Mean First Passage Time (MFPT). The average time taken by the random walker to arrive for the first time at a specific node i, starting from a random initial position j in the network. 11 We consider each couple of nodes (i, j) in the network and repeat the simulation five times for each of them.
The spreading process is a SIR model and we compute the following metric: • Reproduction value R 0 . The average number of individuals infected by the first one, with a single random node infected as seed.

S2 Execution time comparison
The egocentric perspective, that ignores interactions among neighbors of each ego node, implies a huge simplification with respect to mining standard motifs. Traditional techniques for motifs mining indeed rely on an isomorphism test for assessing sub-network equivalence, which is a major bottleneck for the entire procedure. For this reason, standard motifs mining techniques usually limit the search to small motifs containing a handful of nodes. The strength of ETN-gen lies in the possibility of encoding neighborhoods into a unique bit vector, boiling down sub-network equivalence to bit vector matching. This hence results in a very computationally efficient model, and the time required for network generation is drastically lower than that of the other methods. This is evident from Table S1, where we report the time (in seconds) required to generate networks for the three face-to-face datasets with all the methods. ETN-gen is more than 15 times faster than the fastest state-of-the-art method on each network, and there is a difference in time of three orders of magnitude with the slowest one.

S2.1 Computational complexity and space complexity
In this section, we report the time and space complexity of our model. Figure 1  The overall complexity is thus O(n · m orig · d k · log d k + n · m gen · d).

Time complexity. As depicted in
Note that for reasonable values of k, d k is independent of the size of the network, so that the overall complexity is O(n · m gen ), assuming that m gen ≫ m orig .

S3 Scalability
To show the scalability of our approach we extend the analysis to other seven networks, briefly described below.
• High school 2. 39 The As stated by the research group responsible for the data collection, a signed informed consent was obtained for each study participant (all involved students were at least 18). Moreover, the study was approved by the "Commission Nationale de l'Informatique et des Libertés" (CNIL, http://www.cnil.fr), the French national body responsible for ethics and privacy, and by the high school authorities. More details can be found in the paper describing the data collection. 72 • Primary school. 73 The dataset has been collected in a primary school in France, • SMS 2. 16 The dataset represents SMSs among members of a young-family residential living community adjacent to a major research university in North America.
Number of edges: 153, number of nodes: 85. The dataset was collected within the Friends and Family Study and the data collection was approved by the Institutional Review Board (IRB). The participation was optional and each study participant was asked to explicitly adhere.
• Calls 1. 17 The dataset represents phone calls among university freshmen students in the Copenhagen University. Number of edges: 605, number of nodes: 525.
The dataset was collected within the Copenhagen Network Study and the data collection was approved by the Danish Data Supervision Authority. Each study participant was asked to sign an informed consent.
• Calls 2. 16 The dataset represents phone calls among members of a young-family residential living community adjacent to a major research university in North America. Number of edges: 432, number of nodes: 129. The dataset was collected within the Friends and Family Study and the data collection was approved by the Institutional Review Board (IRB). The participation was optional and each study participant was asked to explicitly adhere.
Each face-to-face interaction network has been aggregated with a temporal resolution of five minutes, while SMS and phone calls networks have been aggregated within ten minutes. We opt for this different aggregations due to the natural sparsity of SMS and phone calls networks.
In Figure S1 we show the original number of interactions (in black) and those generated by our method (in orange) for each network. The figure clearly shows the ability of our method in mimicking day/night and week/weekend periodicity. Moreover, our algorithm perfectly operates with different network sizes in both number of individuals and temporal length. Finally, our method is able to capture multiple picks within the same day, that could be associated to the period before and after lunch (i.e. high schools).

S5 Additional datasets: topological similarity
In this section we show the effectiveness of ETN-gen when using alternative temporal networks as original graphs. We test some additional face-to-face interactions networks, then we consider remote communication interactions like SMS and calls networks, for a total of 10 different temporal datasets. We compare ETN-gen results with TagGen as a sole alternative method. This choice is mainly due to time constraints: the other methods would require a very long time to complete the generation process when dealing with these large datasets (see Section S2). Moreover, TagGen is the only state-of-theart algorithm able to always reproduce the same exact number of nodes of the input network, and the only method able to capture intrinsic periodicity of the network.

S5.1 Other face-to-face interactions networks
In the Main Text we show how to generate surrogate networks that mimic three face-toface interaction datasets, by making use of ETN-gen and three other alternative methods.
Here, we focus on three additional face-to-face interaction datasets, namely High school 2, High school 3 and Primary school. Kolmogorov-Smirnov distances of the metrics described in the Main Text (see Methods) are shown in Figure S6. In Figure S7 we report the topological similarity between the aggregated original and generated networks.  Figure   S6 for measures on the aggregated networks. Figure S8 shows the distances among original and generated distributions of the chosen topological metrics. As expected, the methodology we propose is not able to capture metrics correlated to long-term memory. In Figure S9 we report the topological similarity between the aggregated original and generated networks.   Figure   S8 for measures on the aggregated networks.

S6 Additional datasets: dynamical similarity
Here we report Kolmogorov-Smirnov distances between original and generated networks in terms of random walks (coverage and mean first passage time) and the R 0 over a SIR model. We consider three different starting points: t = 0, t = len(G)/2 (in the middle point of the temporal extension of the graph), and the time corresponding to the first peak of connections (when the number of connections reaches a maximum). Figure S10 shows that in the random walk process ETN-gen networks are able to capture coverage better than the TagGen ones, while these appear more similar to the original ones for what concerns the mean first passage time. There are no particular differences when changing the starting point. Figure S11 shows that for the spreading model the differences in the obtained distributions of R 0 between ETN-gen and TagGen are leveled out (and in some cases ETN-gen is performing better).

S6.2 SMS and phone calls networks
The situation is a bit different for what concerns the remote interactions, which are characterized by more sparse networks. In particular from Figure S12 we observe a lower similarity when the starting point is 0 and a much larger similarity for the other starting points. This is probably due to the noise inserted in the process when starting from one of the less connected temporal layers (time 0) in such sparse networks. Figure S13 shows a general good ability of ETN-gen networks to reproduce the R 0 distributions of the SIR model.

S7 Topological similarity on one larger network
The purpose of our algorithm is to capture a high temporal resolution, on the other hand, the state-of-the-art methods have been developed for daily (or weekly) snapshots on bigger networks. For this reason, we evaluate the performance of our algorithm in generating a temporal network with a lower temporal resolution (one day). In particular, we used the same metrics used in 33 on the DNC dataset. 74 The DNC dataset is the network of emails of the Democratic National Committee that was leaked in 2016. The network is composed of 1579 nodes, 33378 temporal edges and 3911 unique edges.
To evaluate the generated network, we used the same metrics used in, 33 in particular, they studied the similarity between the generated and original networks computing

S8 Varying K
In this section we evaluate the performance of our method when k varies between 1 and 5. Figure S15 shows the number of interactions and we observe that as much as k increases, the average number of interactions tend to decrease. Figure S16 instead shows the topological similarity of several metrics with the original network. In general we observe that the differences in the topological measures are not significant in the range of k between 2 and 4 (see for instance density and number of connected components in all datasets), except for some individual cases (like hour closeness in the hospital dataset where clearly increasing k decreases similarity, or the average shortest path length in the High school where the opposite is true). As one may expect as far as k increases, the execution time increases (see Table S2).

S9 Multiple versus single probabilistic model
In this section, we show that using a unique probabilistic model does not capture the daily/night periodicity. However, we are able to capture the average number of interactions.
In the first panel of Figure S17, In conclusion, it is true that using multiple probabilistic models stores more information of the input network. However, even using a unique probabilistic model, ETN-gen performs better than the other state-of-the-art models.    Figure S19 for measures on the aggregated networks. S11 Mesoscale structures

S11.1 Communities
As observed in the main text, ETN-gen is based on an egocentric perspective that does not allow to preserve some of the large-and meso-scale characteristics of spatial organization of the networks, like the existence of communities. In Figure S21 we report a community detection analysis performed on the original and generated networks. We first obtained a partition of the aggregated networks using the Louvain algorithm 45 and then we computed modularity according to Clauset et al. 46 We observe that, while the original networks are characterized by a certain level of modularity, none of the methods for surrogate networks is able to reproduce this feature.

S11.2 Motifs
We tested the generated networks for the emergence of static and temporal motifs. We first investigated the presence of simple static motifs as those reported in Figure S22 on the left. We observe that ETN-gen allows the formation of these motifs with a similar amount to those appearing in the original graphs.
We also tested a posteriori the existence of egocentric temporal neighborhoods in the generated networks. We report in Table S3 the cosine distance between the number of occurrences of the egocentric temporal neighborhoods in original and generated networks. We limited the analysis to the most significant neighborhoods in the original graph. We used the concept of significant structures as reported in 40 and inspired by. 75 As expected, the networks generated with ETN-gen accurately preserve these structures.

S12 Different distances between distributions
In the Main Text we assessed the similarity between metrics distributions using the Kolmogorov-Smirnov distance. Here we report the definitions and results with three additional alternative distances: Kullback-Leibler divergence, Jensen-Shannon divergence, Earth mover's distance.
The Kullback-Leibler divergence, 76 given a population X = x 1 , . . . , x n and two probability distributions p(x) and q(x), measures the information lost when q(x) is used to approximate p(x). Formally, it is defined as: While the Kullback-Leibler divergence is an asymmetrical measure, the Jensen-Shannon divergence 77 provides a similar measure that is symmetric in nature. Formally it is defined as: Where M is the mixture distribution of p(x) and q(x).
The Earth mover's distance, 78 also referred to as Wasserstein distance, quantifies the minimum amount of mass required to be moved to transform one distribution into another, effectively measuring their dissimilarity. Formally, it is defined as follow: EMD(p(x), q(x)) = min λ∈τ(p(x),q(x)) ∑ (x,y)∈X×X λ(x, y) · c(x, y) Where τ(p(x), q(x)) represents the set of all possible joint distributions λ that have p(x) and q(x) as marginals. λ(x, y) is the amount of mass transported from point x in p(x) to point y in q(x), and c(x, y) is the cost of transporting one unit of mass from x to y.
In Tables S4, S5 and S6, we report these three distances together with the Kolmogorov-Smirnov distance for hospital, workplace and high school networks respectively. Despite variations in the magnitude of the distance or divergence observed among different measures, the relative rankings of the measures remain stable and the ETN-gen networks tendentially result the most close to the original ones.