Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

# Evolution of cooperation on temporal networks

## Abstract

Population structure is a key determinant in fostering cooperation among naturally self-interested individuals in microbial populations, social insect groups, and human societies. Traditional research has focused on static structures, and yet most real interactions are finite in duration and changing in time, forming a temporal network. This raises the question of whether cooperation can emerge and persist despite an intrinsically fragmented population structure. Here we develop a framework to study the evolution of cooperation on temporal networks. Surprisingly, we find that network temporality actually enhances the evolution of cooperation relative to comparable static networks, despite the fact that bursty interaction patterns generally impede cooperation. We resolve this tension by proposing a measure to quantify the amount of temporality in a network, revealing an intermediate level that maximally boosts cooperation. Our results open a new avenue for investigating the evolution of cooperation and other emergent behaviours in more realistic structured populations.

## Introduction

Explaining the evolution of durable, widespread cooperative behaviour in groups of self-interested individuals has been a challenge since the time of Darwin1,2,3,4,5,6,7,8. In response, researchers have turned to the critical role played by the underlying interaction networks, in which nodes represent individuals and links represent interactions9,10. It has been shown that the nontrivial population structures represented by both homogeneous2,3,4,9,11,12,13 and heterogeneous10,14,15 networks permit the formation of stable clusters of cooperators (altruists), which achieve higher individual payoffs while also resisting exploitation from defectors (egoists). As such, both theoretical analysis4,9,10,15,16,17,18,19,20 and behavioural experiments21,22,23,24,25,26,27,28 point to network structure as a key ingredient for the emergence of cooperation.

However, these and other deep insights about the evolution of cooperation generally rely on a key assumption that the underlying interaction network (contact graph) of individuals is time-invariant (i.e., static). In practice, this assumption is often violated, especially in social networks, which tend to be formed from an ever-changing amalgam of short-lived interactions. For example, emails and text messages represent near-instantaneous and hence ephemeral links in the corresponding temporal network29. Even in cases where interactions have non-negligible durations—such as phone calls, or the face-to-face interactions between inpatients in the same hospital ward—the network structure is in constant flux.

Recently, it has been shown that the temporality of edge activations can noticeably affect various dynamical processes, ranging from the information or epidemic spreading30,31,32,33 to network accessibility34 to controllability35. It is natural to expect that temporality will have a similarly profound effect in social systems, in which the relevant dynamical laws are strongly tied to the presence (or absence) of network links. There is a large body of work studying coevolutionary dynamics—in which the changes to the network structure are a direct result of the underlying dynamics (e.g., players strategically switching partners to shun defectors)36,37,38,39,40,41. Yet these mechanisms, though important, are just a few among many that influence the structure of real social networks, stressing the importance of studying temporality exogenous to the social dynamics. On this front, we mention one notable work that explored the impact of temporal social contacts on the evolution of cooperation, and claimed that the temporal dynamics of social ties favours selfish behaviour42. And yet, given some profound advantages of temporal networks recently discovered in the context of dynamics and control35, we are compelled to ask whether, under certain circumstances, temporality might actually enhance cooperation.

Here we study the evolution of cooperation on empirical and synthetic temporal networks first, and surprisingly, we find that temporal networks can facilitate the evolution of cooperation. We further investigate the impacts of bursty behaviour (namely, short timeframes of intense activity followed by long windows of relative silence)—a hallmark of many real social interaction patterns43,44. We find that this facet of temporality is actually detrimental to the emergence of cooperation, instead facilitating the spread of egoists. Finally, we rationalise the previous findings by introducing a measure of temporality in networks, and show analytically that an intermediate level most favours cooperation. We confirm the generality of our results over different types of synthetic networks, varying interaction time scales, updating rules (both synchronous and asynchronous), and game dynamics.

## Results

### Modelling framework

We conduct our investigation in the setting of classic evolutionary game theory9,11,14, in which two players interact by each choosing a strategy of cooperation (C) or defection (D). When their strategies agree, each player receives a payoff $$R$$ ($$P$$) for mutual cooperation (defection). When the players’ strategies disagree, the defector receives a payoff $$T$$ while the cooperator receives $$S$$. These outcomes can be encoded in the payoff matrix

$$\begin{array}{c} \quad {\mathrm{C}} \quad {\mathrm{D}}\\ \begin{array}{c}{\mathrm{C}}\\ {\mathrm{D}}\end{array}\left(\begin{array}{cc}R & S \\ T & P\end{array}\right)\end{array}$$

whose entries give the payoff under all possible combinations of strategies. For simplicity, we shall first focus on the widely-studied case of the (weak) Prisoner’s Dilemma9,14,45,46, which without loss of generality corresponds to the setting $$R = 1,T = b$$ and $$S = P = 0$$. This leaves a single temptation parameter, $$b \, > \, 1$$, which captures the potential advantage of defecting over cooperating9.

Figure 1 illustrates the essence of our modelling framework. We consider the above game played out between pairs of adjacent nodes on a time-varying network, which we represent by a sequence of separate networks (snapshots) on the same set of $$N$$ nodes. Starting from empirical contact sequences (i.e. timestamped interactions), these snapshots are constructed by aggregating social contacts over successive, non-overlapping windows of $$\Delta t$$ (Fig. 1a and b), which determines the set of links active in a given snapshot. As a point of comparison, we also create a corresponding static network by aggregating all social contacts in the dataset.

To capture the interactions occurring on these networks, we initially set an equal probability for each individual (node) to choose C or D in the population on the first snapshot. In each round, every individual $$i$$ plays the above game with each of its neighbours, accumulating a total payoff $$P_i$$. Afterwards, the player may change his or her strategy by randomly imitating that of a neighbour. In our simulations, we employ a commonly used updating rule that models a tendency to imitate success14. Specifically, each player $$i$$ may pick a neighbour $$j$$ (having payoff $$P_j$$) from its $$k_i$$ neighbours, and then imitate $$j$$’s strategy with probability $$(P_j - P_i)/(Dk_d)$$ provided $$P_j \, > \, P_i$$. Otherwise, player $$i$$ keeps his/her current strategy. Here $$D = T - S$$ and $$k_d$$ is the larger of $$k_i$$ and $$k_j$$. We repeat this procedure a total of $$g$$ times before changing the network structure to the next snapshot (Fig. 1c). In this way, $$g$$ is a parameter that controls the timescale difference between the dynamics on the network versus the dynamics of the network. We continue running the game for a total of $$G$$ rounds, and then measure the average fraction of cooperators ($$f_{\mathrm{c}}$$) over another 2,000 rounds, similar to the canonical procedure used in static networks14,15. Note that, in a departure from previous studies36,37,38,39,40,41, here the time-varying nature of the networks is completely exogenous, not being coupled to the game dynamics (by, for example, players changing whom they interact with to shun defectors). This allows us to independently study the effect of network temporality on the dynamics of the game.

### Temporal networks facilitate the evolution of cooperation

Our principal result is that temporal networks generally enhance cooperation relative to their static counterparts. What’s more, they allow it to persist at higher levels of temptation, $$b$$. Figure 2 shows the equilibrium fraction of cooperators $$f_{\mathrm{c}}$$ for temporal networks formed from social contacts in four empirical datasets: attendees at a scientific conference (ACM conference)47, students at a high school in Marseilles, France in two different years48,49 (Student 2012, and Student 2013), and workers in an office building in France (Office 2013)50. In each of these systems we observe a broad range of $$g$$ over which $$f_{\mathrm{c}}$$ is greater in the temporal network than in its static counterpart, at almost all values of $$b$$. Strikingly, this is true even for small $$\Delta t$$; in this case the network’s links are distributed over a large number of snapshots, leaving little network scaffolding on which to build stable clusters of cooperators. Nonetheless, there exists a range of $$g$$ that can compensate for this sparsity, again giving temporal networks the victory in terms of enhancing cooperation. Indeed, we find that the only scenario in which temporal networks result in less cooperation than static networks is when $$g$$ is small. In this limit, the evolutionary timescale is comparable to the dynamical timescale, and patterns of cooperation have no time to stabilise before being disrupted by the next change in network structure. This squares our results with the previously-mentioned conclusion that temporality inhibits cooperation (Supplementary Fig. 1), which was obtained from the regime of a single game per snapshot ($$g = 1$$) with comparatively infrequent strategy updates42. Interestingly, regardless of the value of $$g$$, our simulations show a rapid and on-average monotonic convergence of the cooperator fraction toward equilibrium (Supplementary Fig. 2)—similar to the temporal profile previously found in co-evolving random networks51.

As there are many factors that might affect evolutionary outcomes15,52,53, we have studied numerous alternative setups as well. These include: (i) using the original time scale of network edges (Supplementary Fig. 1), (ii) asynchronous updating of strategies (Supplementary Fig. 3), (iii) alternative social dilemmas like the canonical Stag-Hunt ($$S \, < \, P \, < \, T \, < \, R$$) and Snowdrift ($$P \, < \, S \, < \, R \, < \, T$$) games, and the general Prisoner’s Dilemma with $$S \, < \, P$$ (Supplementary Figs. 4 and 5), and finally (iv) a different strategy update rule that allows players to imitate worse-performing neighbours54 (Supplementary Fig. 6). None of these modifications alter our main finding that time-varying network structure generally enhances the evolution of cooperation.

To test whether this result depends on idiosyncrasies of the temporal patterns in real social systems, we have also simulated games on synthetic temporal versions of Erdős-Rényi (ER)55 and scale-free (SF)56 networks (see Methods). Here too we find that with almost any level of temporality, cooperators have an easier time gaining footholds in the population (Fig. 3). Interestingly, we find that temporal versions of SF networks yield a higher $$f_{\mathrm{c}}$$, all other things being equal, than the temporal ER networks (Fig. 3 and Supplementary Fig. 7). As such, the well-known result that heterogeneous degree distributions enhance cooperation in static networks also holds in temporal networks14. Note that our results here are robust to changes in the size and average connectivity of the networks under consideration (Supplementary Figs. 7 and 8).

### Effects of burstiness on the evolution of cooperation

Analyses of the temporal patterns of human interactions in email57, phone calls57,58, and written correspondence43 have revealed a high degree of burstiness—periods of intense activity punctuated by relative lulls—resulting in a heavy-tailed inter-event time distribution43. Such temporal correlations in activity have been shown to have effects on network dynamics above and beyond those of temporality alone, for instance accelerating the spread of contagions59,60. We have established that burstiness is present to varying degrees in each of the four datasets we study (Supplementary Fig. 10), prompting us to ask whether it helps or hinders the evolution of cooperation.

We address this question by shuffling each dataset, randomising the source, target, and timestamp of each social contact (see Methods). We stress that this randomisation has the effect of erasing bursty behaviour at the level of individual nodes. Figure 4 shows that, in every temporal network we consider, cooperation is improved after randomisation, suggesting that bursty behaviour impedes the evolution of cooperation. Indeed, due to the heterogeneity of active times embedded in bursty behaviour of different players, it is harder for cooperators to form stable clusters to obtain benefits from mutual cooperation in order to compensate for the losses against defectors9,25. For the effects of other null models that permute only the structure or the time stamps of the contacts, please refer to Supplementary Figs. 1114, where we also show that the above results are robust to alternative randomisation protocols. Furthermore, this is true for nearly all choices of parameters $$\Delta t$$, $$g$$, and $$b$$. But how do we reconcile the fact that burstiness is inimical to cooperation with our previous observation, namely that temporality generically promotes it?

### Cooperation is maximised at intermediate temporality

The burstiness and the parameters $$g$$ and $$\Delta t$$ encode three different facets of temporality. Specifically, $$g$$ captures the relationship between the dynamical/structural timescales; $$\Delta t$$ on the other hand indicates the extent to which the network structure is spread over time; finally, the burstiness represents time correlations in the network structure. To understand the effects of these parameters in a unified way, we define the following measure of the temporality $${\cal{T}}$$ of a temporal network with $$M$$ snapshots as

$${\cal{T}} = \frac{1}{{M - 1}}\mathop {\sum}\limits_{m = 1}^{M - 1} {\frac{{\mathop {\sum}\nolimits_{i,j} {| {a_{ij}(m) - a_{ij}(m + 1)} |} }}{{\mathop {\sum}\nolimits_{i,j} {{\mathrm{max}}\{ {a_{ij}(m),a_{ij}(m + 1)} \}} }}} .$$

Here $$a_{ij}(m)$$ is the connectivity between nodes $$i$$ and $$j$$ in snapshot $$m$$, being $$1$$ if the nodes have a contact in the associated time window and $$0$$ otherwise; the above fraction equals $$0$$ for any two nearby empty networks without links. This measure captures the tendency of a randomly-chosen link to change status (either active to inactive, or vice versa) in the next snapshot. By construction, we always have $$0 \, < \, {\cal{T}} \le 1$$, with $${\cal{T}} = 0$$ occurring in the limit where network topology does not change (i.e. a static network), and $${\cal{T}} = 1$$ corresponding to the case where all links in a given snapshot are different from those in the previous snapshot.

Figure 5 shows the values of $${\cal{T}}$$ for both the original and randomised versions of each of the four datasets we study. We see that at $$\Delta t = 1$$, the original data tend to display high temporality, which decreases upon randomisation, suggesting that most interactions (links) in these systems last less than $$1$$ hour. Considering our earlier finding that the cooperation level $$f_{\mathrm{c}}$$ increases after randomisation (Fig. 4), this suggests that too-high temporality hinders the spread of cooperation, instead fostering egoistic behaviour. On the other hand, we find that a too-low value for $${\cal{T}}$$ is also associated with diminished cooperation (Supplementary Fig. 16). Altogether, the picture that emerges is one of an intermediate regime—a sweet spot of temporality at which cooperation is maximally enhanced relative to static systems.

### Theoretical analysis

Having demonstrated that an intermediate level of $$\Delta t$$ facilitates cooperation most, we are prompted to theoretically explain this observation. We model temporal networks theoretically using the activity-driven model33. Here, a node can either be active—in which case it forms links with an average $$l$$ randomly-chosen other nodes—or inactive, in which case its links (if any) come from other active nodes. We denote by $$a_i$$ the probability that node $$i$$ is active in a given snapshot. Let $$N_a$$ denote the total number of players in the snapshot $$m$$ having a specified activity value $$a$$, and let $$D_a^m$$ denote the expected number of those that are defectors. Also, we will denote by $$\mu$$ ($$\lambda$$) the average probability for a defector (cooperator) to become a cooperator (defector) in the next round.

Staring from a specific snapshot $$m$$, the number of defectors in the next snapshot, $$D_a^{m + 1}$$ arises as a sum of three contributions: (a) defectors in the current snapshot (i.e. $$D_a^m$$), minus (b) the number of them that convert to cooperators (i.e. $$\mu D_a^m$$), plus (c) the new defectors converted from cooperators in the last round. Note that, in (c), new defectors can arise either as (i) active cooperators who interact with (and imitate) neighbouring defectors (i.e. $$(N_a - D_a^m)al\left( {{\int} {\mathrm{d}}a^{\prime}D_{a^{\prime}}^m/N} \right)\lambda$$), or (ii) inactive cooperators who nonetheless share a link with an active defector and imitate that defector’s strategy (i.e. $${\int} {{\mathrm{d}}a^\prime D_{a{^\prime}}^ma^\prime l\left[ {\left( {N_a - D_a^m} \right)/N} \right]\lambda }$$, where $$(N_a - D_a^m)/N$$ is the probability that cooperators with active probability $$a$$ are selected to interact with an active defector). Combining these contributions, we can write a self-consistent equation for the evolution of $$D_a^m$$

$$D_a^{m + 1} = D_a^m - \mu D_a^m + \left( {N_a - D_a^m} \right)al{\int} {{\mathrm{d}}a^\prime D_{a^{\prime}}^m\frac{\lambda }{N}} + {\int} {{\mathrm{d}}a^\prime D_{a^{\prime}}^m a^{\prime} l\frac{{N_a - D_a^m}}{N}\lambda } .$$
(1)

When we take the continuum limit with respect to the time $$m$$, the above equation corresponds to the following system of differential equations

$$\left\{ {\begin{array}{*{20}{l}} {\partial _mD = - \mu D + \lambda l\langle a\rangle D + \lambda lQ} \hfill \\ {\partial _mQ = - \mu Q + \lambda l\langle a^2\rangle D + \lambda l\langle a\rangle Q} \hfill \end{array}\, ,} \right.$$
(2)

where $$D$$ is the number of defectors, $$Q = {\int} {\mathrm{d}}aD_aa$$, and $$\langle a\rangle$$ ($$\langle a^2\rangle$$) is the first (second) moment of $$a$$ over all players. The first expression in Eq. (2) is obtained by integrating over all values of $$a$$ and ignoring the second order terms (i.e. $$Q^mD^m$$ here). The second expression comes from multiplying both sides of Eq. (2) by $$a$$ and then integrating out (see Supplementary Note 1 for details). Regardless of the parameter values, this system possesses an equilibrium at $$D = Q = 0$$, corresponding to the complete absence of defectors. We can determine its stability by linearising to obtain the corresponding Jacobian matrix

$$J = \left( {\begin{array}{*{20}{l}} { - \mu + \lambda l\langle a\rangle } \hfill & {\lambda l} \hfill \\ {\lambda l\langle a^2\rangle } \hfill & { - \mu + \lambda l\langle a\rangle } \hfill \end{array}} \right),$$

which has eigenvalues $$- \mu + \lambda l\langle a\rangle \pm \lambda l\sqrt {\langle a^2\rangle }$$. When the largest eigenvalue is positive (equivalent to $$\lambda /\mu \, > \, 1/[(\langle a\rangle + \sqrt {\langle a^2\rangle } )l]$$), the equilibrium is unstable, meaning that defectors can never die out in the population. Interestingly, this equation is consistent with the epidemic threshold previously derived for activity-driven temporal networks33, where there $$\lambda$$ is the infection rate per contact and $$\mu$$ is the recovery rate. Indeed, whether defection or infection, the denominator captures the rate of spread of a small perturbation around an equilibrium (in this case $$D = 0$$), with both density ($$\langle a\rangle$$) and degree heterogeneity ($$\langle a^2\rangle$$) facilitating that spread.

The threshold for defection to gain a foothold in the population can be related to the network structure as follows. Considering that the average number of links for each player is $$k = 2l\langle a\rangle$$, we know that the probability for a defector to spread its strategy is $$\lambda k$$. Hence a nonzero fraction of defectors will break out if $$\lambda k/\mu \ge {\cal{D}}^ \ast$$, where $${\cal{D}}^ \ast$$ is the threshold defined by

$${\cal{D}}^ \ast = \frac{{2\langle a\rangle }}{{\langle a\rangle + \sqrt {\langle a^2\rangle } }}.$$
(3)

We see that the increase of defectors is triggered (inhibited) by $$\lambda$$ ($$\mu$$), where the bigger (smaller) $$\lambda$$ ($$\mu$$) is, the more cooperators (defectors) switch to be defectors (cooperators). Therefore, beyond the criterion $$\lambda k/\mu \ge {\cal{D}}^ \ast$$ governing the existence of defectors, $${\cal{D}}^ \ast$$ quantifies the difficulty for defectors to take over the whole network. Numerical validations for this threshold are shown in Supplementary Fig. 17, where we also show our analytical approximations of this threshold agree with the findings of canonical evolutionary dynamics in the case where a strategy’s payoff determines the change of its frequency.

Equation (3) tells us that the defection threshold in an activity-driven temporal networks is in part determined by the typical activity level $$a$$ of its nodes. To obtain the value of $${\cal{D}}^ \ast$$ for a given temporal network, we can estimate the activity probability of node $$i$$ in the snapshot $$m$$ as $$a_i^m = k_i^m/k_i$$, where $$k_i^m$$ and $$k_i$$ are the degree of $$i$$ in the snapshot and the corresponding static network. The average activity over a given snapshot $$m$$ with $$N$$ individuals is then $$a^m = \mathop {\sum}\nolimits_{i = 1}^N a_i^m/N$$. Then for the jth moment of $$a$$ of the whole temporal network with $$M$$ snapshots, we calculate it by $$\langle a^j\rangle \approx \mathop {\sum}\nolimits_{m = 1}^M (a^m)^j/M$$. For each of the empirical datasets we study, we find that the threshold for the outbreak of defection reaches its maximum when $$\Delta t$$ is at an intermediate level (Fig. 6), echoing our previous result of a Goldilocks regime of temporality maximally conducive to cooperation.

We can understand the link between the model predictions and the data by rewriting the threshold (3) as $${\cal{D}}^ \ast = \frac{2}{{1 \, + \, \sqrt {1 \, + \, {\mathrm{Var}}(a)/{\mathrm{E}}^2(a)} }}$$, where $${\mathrm{Var}}(a) = \langle a^2\rangle - \langle a\rangle ^2$$ and $${\mathrm{E}}(a) = \langle a\rangle$$ For small $$\Delta t$$, individuals tend to be less active in each sparse snapshot (small $${\mathrm{E}}(a)$$ implies small $${\cal{D}}^ \ast$$), which in turn gives more chance for defectors to spread their strategy pairwisely as it is the Nash equilibrium. For large $$\Delta t$$, however, due to the heterogeneity of interactions over different snapshots (large $${\mathrm{Var}}(a)$$ implies small $${\cal{D}}^ \ast$$), clusters of cooperators have less chance to stabilise. Only at an intermediate $$\Delta t$$ can cooperators outspread defectors, and the combination of high $${\mathrm{E}}(a)$$ and low $${\mathrm{Var}}(a)$$ leads to a high barrier to defection ($${\cal{D}}^ \ast \approx 1$$) (Fig. 6).

## Discussion

We have shown that temporal networks, both empirical and synthetic, generically enhance the emergence of cooperation relative to their static counterparts. Remarkably, this central finding holds even after the underlying contact sequences are randomised, thereby destroying topological (e.g. clustering) or temporal (e.g. bursts) correlations in the data. Altogether, this suggests that temporality—and temporality alone—is sufficient to improve cooperation. Indeed, after randomisations, we find that the level of cooperation is actually improved, demonstrating that the bursty nature of human interactions hinders the maintenance of cooperation to some degree. Finally, we demonstrate that the temporality of a network determines the fate of cooperators, with cooperators flourishing at intermediate values of network temporality.

The temporal networks considered here should be contrasted with coevolutionary dynamics, in which the changes in network structure are tied to the dynamics of the relevant social dilemmas. For example, several important mechanisms elucidate that cooperation can be boosted by strategic migration36,40, and deliberate switching of interaction partners to avoid defectors37,61,62. However, it is unlikely the temporality characterising real social interactions is driven exclusively (or even primarily) by strategic switching in pursuit of a given objective47,48,49,50. This underscores the importance of studying cases in which the temporality is exogenous to the game dynamics, allowing an independent assessment of how the former affects the latter. As such, the agnostic view of the nature of temporality we have taken here represents a fundamental strength of our approach.

We have shown that our main conclusions are not artifacts of the specific empirical networks considered here, nor do they qualitatively change under different parameterisations. Nonetheless, future investigations such as appropriate behavioural experiments that incorporate network temporality and relevant phenomena like burstiness are warranted. Though we have shown that our results are unchanged when considering only subsets of the network (Supplementary Fig. 18), disregarding very short-lived contacts (Supplementary Fig. 19), changing the clustering coefficient (Supplementary Figs. 20 and 21), or using different starting network types (Supplementary Fig. 22), real systems display considerable variability, including different characteristic timescales for population evolution (Supplementary Fig. 23). Accordingly, future analysis of interactions at different spatial and temporal scales will be necessary to understand the full implications of temporality. Toward this end, the long tradition of combining tools from network science and statistical physics63 with evolutionary game theory will no doubt continue to pay dividends.

Another natural extension of the current work is to consider group interactions, which involve the interactions among individuals who are not directly connected with one another64,65,66. These interactions generate much more dynamical complexity than pairwise interactions alone67. In microbial populations, for example, pairwise outcomes can predict the survival of three-species competitions with accuracy as high as 90%, yet information on the outcomes of three-species competition is still needed in order to predict scenarios over larger numbers of species with high accuracy68. Moreover, the menu of strategies can be expanded beyond the simple dichotomy of cooperation versus defection, which represents only one axis of a broader landscape of moral behaviour69. For example, three-strategy games analogous to rock-paper-scissors may present a more nuanced picture of the detailed interactions characterising microbial communities, ecosystems, and human societies alike.

## Methods

### Empirical temporal networks and datasets

We construct temporal networks from empirical datasets collected by the SocioPatterns collaboration (http://www.sociopatterns.org) by aggregating contacts into undirected network links over time windows of $$\Delta t$$ (Fig. 1a). Thus the active time interval for the snapshot $$m$$ is from $$(m - 1)\Delta t$$ to $$m\Delta t$$, and a link between $$i$$ and $$j$$ exists in that snapshot if players $$i$$ and $$j$$ interact at least once in that time period (Fig. 1b). We obtain a static network in the limit where $$\Delta t = {\Bbb T}$$, where $${\Bbb T}$$ is the last timestamp in the data, resulting in a single snapshot containing all links.

### Synthetic temporal networks

We generate temporal analogues of networks with heterogeneous or homogeneous degree distributions with specified network size $$N$$ and average degree $$\langle k\rangle$$ by first generating a base static network, using the static model70 and the Erdős-Rényi model55, respectively. We then form $$M$$ snapshots by randomly and independently choosing a fraction $$p$$ of edges to be active in each one. We have verified that our results hold under more sophisticated generative models that build temporal networks from a static network backbone, such as the activity-driven model33.

### Randomisations of empirical datasets

We consider four widely-used null models29 to randomise the empirical datasets: Randomised Edges (RE) where we randomly choose pairs of edges $$(i,j)$$ and $$(i^{\prime},j^{\prime})$$, and replace them with $$(i,i^{\prime})$$ and $$(j,j^{\prime})$$ or $$(i,j^{\prime})$$ and $$(j,i^{\prime})$$ with equal probability provided this results in no self loops; Randomly Permuted Times (RPT), where we shuffle the timestamps of the contacts, leaving their sources and targets unaltered; Randomly Permuted Times + Randomised Edges (RPTRE) which consists first of RPT followed by RE; and Time Reversal (TR), where the temporal order of the contacts is reversed.

### Reporting summary

Further information on research design is available in the Nature Research Reporting Summary linked to this article.

## Data availability

All empirical datasets analysed in this work are publicly available through the SocioPatterns collaboration (http://www.sociopatterns.org).

## Code availability

The computer codes used in this work are available at https://github.com/leizhougetbetter/TemporalNetworks.

## References

1. Hamilton, W. D. The evolution of altruistic behavior. Am. Nat. 97, 354–356 (1963).

2. Trivers, R. L. The evolution of reciprocal altruism. Q. Rev. Biol. 46, 35–57 (1971).

3. Maynard Smith, J. Group selection. Q. Rev. Biol. 51, 277–283 (1976).

4. Hofbauer, J. & Sigmund, K. Evolutionary Games and Population Dynamics (Cambridge University Press, Cambridge, 1998).

5. Nowak, M. A. Five rules for the evolution of cooperation. Science 314, 1560–1563 (2006).

6. Levin, S. A. Public goods in relation to competition, cooperation, and spite. Proc. Natl Acad. Sci. USA 111, 10838–10845 (2014).

7. Rakoff-Nahoum, S., Foster, K. R. & Comstock, L. E. The evolution of cooperation within the gut microbiota. Nature 459, 255–259 (2016).

8. Lewin-Epstein, O., Aharonov, R. & Hadany, L. Microbes can help explain the evolution of host altruism. Nat. Commun. 8, 14040 (2017).

9. Nowak, M. A. & May, R. M. Evolutionary games and spatial chaos. Nature 359, 826–829 (1992).

10. Allen, B. et al. Evolutionary dynamics on any population structure. Nature 544, 227–230 (2017).

11. Hauert, C. & Doebeli, M. Spatial structure often inhibits the evolution of cooperation in the snowdrift game. Nature 428, 643–646 (2004).

12. Traulsen, A., Claussen, J. C. & Hauert, C. Coevolutionary dynamics: From finite to infinite populations. Phys. Rev. Lett. 95, 238701 (2005).

13. Roca, C. P., Cuesta, J. A. & Sánchez, A. Time scales in evolutionary dynamics. Phys. Rev. Lett. 97, 158701 (2006).

14. Santos, F. C. & Pacheco, J. M. Scale-free networks provide a unifying framework for the emergence of cooperation. Phys. Rev. Lett. 95, 098104 (2005).

15. Santos, F. C., Pacheco, J. M. & Lenaerts, T. Evolutionary dynamics of social dilemmas in structured heterogeneous populations. Proc. Natl Acad. Sci. USA 103, 3490–3494 (2006).

16. Hilbe, C., Röhl, T. & Milinski, M. Extortion subdues human players but is finally punished in the prisoner’s dilemma. Nat. Commun. 5, 3976 (2014).

17. Hilbe, C., Šimsa, Š., Chatterjee, K. & Nowak, M. A. Evolution of cooperation in stochastic games. Nature 559, 246–249 (2018).

18. Gómez-Gardeñes, J., Campillo, M., Floría, L. M. & Moreno, Y. Dynamical organization of cooperation in complex topologies. Phys. Rev. Lett. 98, 1–4 (2007).

19. Li, A., Wu, B. & Wang, L. Cooperation with both synergistic and local interactions can be worse than each alone. Sci. Rep. 4, 5536 (2014).

20. Zhou, L., Li, A. & Wang, L. Evolution of cooperation on complex networks with synergistic and discounted group interactions. Europhys. Lett. 110, 60006 (2015).

21. Fehr, E. & Gächter, S. Altruistic punishment in humans. Nature 415, 137–140 (2002).

22. Milinski, M., Sommerfeld, R. D., Krambeck, H.-J., Reed, F. A. & Marotzke, J. The collective-risk social dilemma and the prevention of simulated dangerous climate change. Proc. Natl Acad. Sci. USA 105, 2291–2294 (2008).

23. Traulsen, A., Semmann, D., Sommerfeld, R. D., Krambeck, H.-J. & Milinski, M. Human strategy updating in evolutionary games. Proc. Natl Acad. Sci. USA 107, 2962–2966 (2010).

24. Rand, D. G., Arbesman, S. & Christakis, N. A. Dynamic social networks promote cooperation in experiments with humans. Proc. Natl Acad. Sci. USA 108, 19193–19198 (2011).

25. Rand, D. G., Nowak, M. A., Fowler, J. H. & Christakis, N. A. Static network structure can stabilize human cooperation. Proc. Natl Acad. Sci. USA 111, 17093–17098 (2014).

26. Xiao, E. & Houser, D. Emotion expression in human punishment behavior. Proc. Natl Acad. Sci. USA 102, 7398–7401 (2005).

27. Gracia-Lázaro, C. et al. Heterogeneous networks do not promote cooperation when humans play a Prisoner’s Dilemma. Proc. Natl Acad. Sci. USA 109, 12922–12926 (2012).

28. Burton-Chellew, M. N., El Mouden, C. & West, S. A. Conditional cooperation and confusion in public-goods experiments. Proc. Natl Acad. Sci. USA 113, 1291–1296 (2016).

29. Holme, P. & Saramäki, J. Temporal networks. Phys. Rep. 519, 97–125 (2012).

30. Masuda, N., Klemm, K. & Eguíluz, V. M. Temporal networks: Slowing down diffusion by long lasting interactions. Phys. Rev. Lett. 111, 188701 (2013).

31. Masuda, N. & Lambiotte, R. A Guide to Temporal Networks (World Scientific, Singapore, 2016).

32. Scholtes, I., Wider, N., Pfitzner, R., Garas, A., Tessone, C. J. & Schweitzer, F. Causality-driven slow-down and speed-up of diffusion in non-Markovian temporal networks. Nat. Commun. 5, 5024 (2014).

33. Perra, N., Gonçalves, B., Pastor-Satorras, R. & Vespignani, A. Activity driven modeling of time varying networks. Sci. Rep. 4, 469 (2012).

34. Lentz, H. H. K., Selhorst, T. & Sokolov, I. M. Unfolding accessibility provides a macroscopic approach to temporal networks. Phys. Rev. Lett. 110, 118701 (2013).

35. Li, A., Cornelius, S. P., Liu, Y.-Y., Wang, L. & Barabási, A.-L. The fundamental advantages of temporal networks. Science 358, 1042–1046 (2017).

36. Helbing, D. & Yu, W. The outbreak of cooperation among success-driven individuals under noisy conditions. Proc. Natl Acad. Sci. USA 106, 3680–3685 (2009).

37. Perc, M. & Szolnoki, A. Coevolutionary games - a mini review. BioSystems 99, 109–125 (2010).

38. Perc, M. Double resonance in cooperation induced by noise and network variation for an evolutionary prisoner’s dilemma. New J. Phys. 8, 1–14 (2006).

39. Meloni, S., Buscarino, A., Fortuna, L., Frasca, M., Gómez-Gardeñes, J., Latora, V. & Moreno, Y. Effects of mobility in a population of prisoner’s dilemma players. Phys. Rev. E 79, 067101 (2009).

40. Li, A., Wu, T., Cong, R. & Wang, L. One step memory of group reputation is optimal to promote cooperation in public goods games. Europhys. Lett. 103, 30007 (2013).

41. Pinheiro, F. L., Santos, F. C. & Pacheco, J. M. Linking individual and collective behavior in adaptive social networks. Phys. Rev. Lett. 116, 128702 (2016).

42. Cardillo, A., Petri, G., Nicosia, V., Sinatra, R., Gómez-Gardeñes, J. & Latora, V. Evolutionary dynamics of time-resolved social interactions. Phys. Rev. E 90, 1–11 (2014).

43. Barabási, A.-L. The origin of bursts and heavy tails in human dynamics. Nature 435, 207–211 (2005).

44. Karsai, M., Jo, H.-H. & Kaski, K. Bursty Human Dynamics (Springer International Publishing, New York, 2017).

45. Rapoport, A. & Chammah, A. Prisoner’s Dilemma: A Study in Conflict and Cooperation. Ann Arbor paperbacks (University of Michigan Press, Ann Arbor, 1965).

46. Szabó, G. & Fáth, G. Evolutionary games on graphs. Phys. Rep. 446, 97–216 (2007).

47. Isella, L., Stehlé, J., Barrat, A., Cattuto, C., Pinton, J.-F. & den Broeckm, W. V. What’s in a crowd? Analysis of face-to-face behavioral networks. J. Theor. Bio. 271, 166–180 (2011).

48. Fournet, J. & Barrat, A. Contact patterns among high school students. PLoS ONE 9, e107878 (2014).

49. Mastrandrea, R., Fournet, J. & Barrat, A. Contact patterns in a high school: A comparison between data collected using wearable sensors, contact diaries and friendship surveys. PLoS ONE 10, 1–26 (2015).

50. Genois, M., Vestergaard, C. L., Fournet, J., Panisson, A., Bonmarin, I. & Barrat, A. Data on face-to-face contacts in an office building suggest a low-cost vaccination strategy based on community linkers. Netw. Sci. 3, 326–347 (2015).

51. Szolnoki, A. & Perc, M. Emergence of multilevel selection in the prisoner’s dilemma game on coevolving random networks. New J. Phys. 11, 093033 (2009).

52. Hindersin, L. & Traulsen, A. Most undirected random graphs are amplifiers of selection for birth-death dynamics, but suppressors of selection for death-birth dynamics. PLoS Comput. Biol. 11, 1–14 (2015).

53. Herrerías-Azcué, F., Pérez-Muñuzuri, V. & Galla, T. Stirring does not make populations well mixed. Sci. Rep. 8, 1–9 (2018).

54. Traulsen, A., Nowak, M. A. & Pacheco, J. M. Stochastic dynamics of invasion and fixation. Phys. Rev. E 74, 011909 (2006).

55. Erdős, P. & Rényi, A. On the evolution of random graphs. Publ. Math. Inst. Hung. Acad. Sci. 5, 17–60 (1960).

56. Barabási, A.-L. & Albert, R. Emergence of scaling in random networks. Science 286, 509–512 (1999).

57. Karsai, M. et al. Small but slow world: How network topology and burstiness slow down spreading. Phys. Rev. E 83, 025102 (2011).

58. Kivelä, M., Pan, R. K., Kaski, K., Kertész, J., Saramäki, J. & Karsai, M. Multiscale analysis of spreading in a large communication network. J. Stat. Mech. Theor. Exp. 2012, P03005 (2012).

59. Rocha, L. E. C., Liljeros, F. & Holme, P. Simulated epidemics in an empirical spatiotemporal network of 50,185 sexual contacts. PLoS Comput. Biol. 7, e1001109 (2011).

60. Takaguchi, T., Masuda, N. & Holme, P. Bursty communication patterns facilitate spreading in a threshold-based epidemic dynamics. PLoS ONE 8, e68629 (2013).

61. Szolnoki, A., Perc, M. & Danku, Z. Making new connections towards cooperation in the prisoner’s dilemma game. Europhys. Lett. 84, 50007 (2008).

62. Szolnoki, A. & Perc, M. Resolving social dilemmas on evolving random networks. Europhys. Lett. 16, 1–14 (2014).

63. Perc, M., Jordan, J. J., Rand, D. G., Wang, Z., Boccaletti, S. & Szolnoki, A. Statistical physics of human cooperation. Phys. Rep. 687, 1–51 (2017).

64. Szolnoki, A., Perc, M. & Szabó, G. Topology-independent impact of noise on cooperation in spatial public goods games. Phys. Rev. E 80, 056109 (2009).

65. Santos, F. C., Santos, M. D. & Pacheco, J. M. Social diversity promotes the emergence of cooperation in public goods games. Nature 454, 213–216 (2008).

66. Cardillo, A., Meloni, S., Gómez-Gardeñes, J. & Moreno, Y. Velocity-enhanced cooperation of moving agents playing public goods games. Phys. Rev. E 85, 067101 (2012).

67. Gokhale, C. & Traulsen, A. Evolutionary games in the multiverse. Proc. Natl Acad. Sci. USA 107, 5500–5504 (2010).

68. Friedman, J., Higgins, L. M. & Gore, J. Community structure follows simple assembly rules in microbial microcosms. Nat. Ecol. Evol. 1, 0109 (2017).

69. Capraro, V. & Perc, M. Grand challenges in social physics: In pursuit of moral behavior. Front. Phys. 6, 107 (2018).

70. Goh, K. I., Kahng, B. & Kim, D. Universal behavior of load distribution in scale-free networks. Phys. Rev. Lett. 87, 278701 (2001).

## Acknowledgements

We thank Professors Kevin Foster, Roberta Sinatra, Márton Karsai, and Dr. Alessio Cardillo for helpful comments and discussions. This work is supported by NSFC (Nos. 61751301 and 61533001). A.L. acknowledges the Cross-Disciplinary Fellowship Award (Grant: LT000696/2018-C) from International Human Frontier Science Program, China Scholarship Council (No. 201406010195) and generous support from Barabási Lab at Northeastern University and Foster Lab at University of Oxford. L.Z. acknowledges the support from China Scholarship Council (No. 201606010270) and the Levin Lab. Q.S. is supported by the Simons Foundation Math+X Grant to the University of Pennsylvania. S.P.C. is supported by the John Templeton Foundation (No. 51977) and NIH (No. P50HG004233). Y.-Y.L. is supported by grants R01AI141529, R01HD093761, U19AI095219, U01HL089856, and UH3OD023268 from National Institutes of Health. S.A.L. acknowledges DARPA grant AWD 1005127.

## Author information

Authors

### Contributions

A.L., Y.-Y.L. and L.W. conceived and designed the project. All authors performed the research. L.Z. and Q.S. performed numerical calculations on the empirical and synthetic data, respectively. A.L. performed all the theoretical calculations. A.L., L.Z., S.P.C., Y.-Y.L., L.W. and S.A.L. analysed the results. A.L., S.P.C., Y.-Y.L., L.W. and S.A.L. wrote the manuscript. L.Z. and Q.S. edited the manuscript.

### Corresponding authors

Correspondence to Yang-Yu Liu, Long Wang or Simon A. Levin.

## Ethics declarations

### Competing interests

The authors declare no competing interests.

Peer review information Nature Communications thanks the anonymous reviewer(s) for their contribution to the peer review of this work.

Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions

Li, A., Zhou, L., Su, Q. et al. Evolution of cooperation on temporal networks. Nat Commun 11, 2259 (2020). https://doi.org/10.1038/s41467-020-16088-w

• Accepted:

• Published:

• DOI: https://doi.org/10.1038/s41467-020-16088-w

• ### Quantifying agent impacts on contact sequences in social interactions

• Mark M. Dekker
• Tessa F. Blanken
• Debabrata Panja

Scientific Reports (2022)

• ### Network structure optimization for social networks by minimizing the average path length

• Wei Du
• Gang Li
• Xiaochen He

Computing (2022)