## Introduction

Cooperation among humans has been found to be quite common in social dilemmas1, 2, and plays a major role in the emergence of complex modern societies3, 4. Therefore, understanding the underlying mechanisms that can give rise to and sustain cooperation from an evolutionary perspective is key to complementing Darwin’s theory of evolution5,6,7,8,9.

In reality, populations are structured, which means that the topology of strategic interactions is given by a network of contacts. In structured populations, individuals interact repeatedly with the same individuals. Thus, as a consequence, cooperators can survive in social dilemmas by forming network clusters. This mechanism is referred to as network reciprocity2, 10. In the well-studied case of lattice topologies, the resulting network clusters unfold in Euclidean space11,12,13 (spatial selection14). Realistic networks of contacts are heterogeneous rather than lattices and often scale-free, which means that their degree distribution follows a power-law with exponent γ (2, 3), where a lower value of γ means more heterogeneous networks. Heterogeneity has been shown to favor cooperation15,16,17, and cooperating nodes form a connected (or network) cluster18. However, the geometric organization of these connected clusters—similarly to spatial selection in Euclidean space—remains elusive.

Real complex networks, in addition to being heterogeneous, exhibit a high mean local clustering coefficient19, 20 (this means that the network contains a high number of closed triangles). This is particularly important because a high clustering coefficient implies the existence of an underlying metric space21.

We show that evolutionary dynamics on scale-free, highly clustered networks lead to the formation of patterns in the underlying metric space, similar to the aforementioned spatial selection in Euclidean space. Using two empirical networks, the IPv6 Internet topology and the arXiv collaboration network, as well as synthetic networks, we show that spatial patterns play an important role in the evolution of cooperation. In fact, under certain conditions metric clusters can even be more effective at sustaining cooperation than the most connected nodes (hubs). As a consequence, heterogeneity does not always favor—but can even hinder—the evolution of cooperation in social dilemmas.

## Results

### Latent geometry of scale-free networks

Real contact networks are usually heterogeneous, and often scale-free, as well as highly clustered20 (we refer to a high mean local clustering coefficient, i.e. a large number of closed triangles19). The effect of scale-free topologies has attracted a lot of attention, and many theoretical studies have found that heterogeneous networks of contacts favor cooperation in social dilemmas15,16,17,18, although this behavior has not been confirmed in recent experiments with human players22. Importantly, the high local clustering coefficients found in real contact networks have been proven to imply the existence of a metric space underlying the observed topology21. This means that the nodes of a given real complex network can be mapped to coordinates in this metric space such that the probability that pairs of nodes will be connected in the observed topology depends only on their distance in the metric space. Specifically, heterogeneous networks can be embedded into hyperbolic space23,24,25. In this representation, each node has a radial and angular coordinate. The radial coordinate abstracts the popularity, and hence the degree of the node, such that hubs are placed closer to the center of the disc (Fig. 1a). The angular coordinate abstracts a similarity space, such that the angular distance is a measure of the similarity between two nodes, whereby nodes tend to connect to more similar nodes. In Fig. 1a, b we show an illustration of the hyperbolic metric structure underlying two different networks (see Methods section for further details). In the following, we show that evolutionary dynamics trigger the formation of stable spatial clusters in the angular dimension on the underlying hyperbolic space.

### Evolutionary dynamics and the emergence of metric clusters

Let us first consider the prisoner’s dilemma game, in particular T = 1.2 and S = −0.2 (see Eq. (1) in Methods) on synthetic contact networks generated with the model described in Methods. This model generates realistic topologies based on underlying hyperbolic metric spaces, similar to Fig. 1a. We simulate the evolutionary game dynamics (see Methods and Fig. 1c) and find that the system tends to self-organize into a state in which groups that are mainly cooperative are clearly separate from groups populated mainly by defectors (see Fig. 2a–c and Supplementary Movie 1)26, 27. Similarly to the case of lattice topologies and spatial selection in Euclidean space, we observe the formation of clusters of cooperators in the angular dimension of the underlying hyperbolic space. In Fig. 2d, we show the evolution of the density of cooperators in different bins of the angular coordinate θ. We observe that initially cooperation decreases (see purple line in Fig. 2e) while, at the same time, the remaining cooperators become concentrated in clusters in the angular space (Fig. 2a). Cooperation then increases again as it spreads in the vicinity of the clusters (Fig. 2b) until the system reaches a stationary state with fluctuations only at the borders of the clusters (Fig. 2c and Supplementary Movie 1).

We quantify the degree to which cooperators and defectors cluster in the angular space using the Kolmogorov–Smirnov (KS) statistic28, which measures the difference between two one-dimensional distributions. The KS statistic is defined as the maximum absolute difference between the values of two cumulative distributions. In particular, we define the KS statistic of the distribution of cooperation density in different angular bins, and the uniform distribution at time t as $$\bar \rho (t)$$ (see Methods for details). A higher value of $$\bar \rho (t)$$ thus denotes more pronounced clustering of cooperators and defectors, respectively. In Fig. 2f, we show the evolution of $$\bar \rho (t)$$ for 103 different realizations (blue lines) and their mean (black line). On average, $$\bar \rho (t)_{}^{}$$ increases initially and approaches a constant value after ~102–103 generations. Among different realizations, $$\bar \rho (t)$$ varies significantly and we study the evolution of its distribution in Fig. 2h. We find that at relatively low times, the distribution shows a peak at $$\bar \rho \approx 0.2$$, which then declines. Eventually (black line), there is a high proportion of realizations with $$\bar \rho \approx 0$$, which must be the case if the system approaches a state with nearly full cooperation or defection. It can also be observed from the evolution of the distribution of cooperation (Fig. 2g) that the probability of high cooperation C ≈ 1 increases over time. In combination, these observations indicate that the evolutionary path toward full cooperation includes a phase of significant clustering of cooperators. The stationary distribution of $$\bar \rho$$ (colored lines converge to the black line in Fig. 2h) shows that apart from the aforementioned realizations, the values of $$\bar \rho$$ are distributed around the mean of $$\bar \rho \approx 0.2$$.

To conclude, evolutionary dynamics on scale-free networks lead to the formation of stable spatial patterns, which can be observed as metric clusters in the angular dimension of underlying hyperbolic metric spaces. This behavior is similar to spatial selection in lattice topologies, where cooperators form spatial clusters in Euclidean space.

Let us illustrate the difference between the discovered metric clusters and connected clusters. A connected cluster, i.e. a subgraph in which each pair of nodes is connected using only paths among the nodes of the subgraph19, is shown in Fig. 3a (blue nodes). This connected cluster was generated following the procedure described in Methods. The similarity (angular) coordinates θ of the nodes belonging to this connected cluster are uniformly distributed. A metric cluster is illustrated in Fig. 3b. Contrarily to the previous case, the similarity (angular) coordinates θ of nodes belonging to the metric cluster by definition lie in a certain interval, here chosen to be [π, 3/2π) (see also Supplementary Fig. 3). Note that the metric cluster in Fig. 3b is also a connected cluster, but the connected cluster in Fig. 3a is not a metric cluster, because the similarity coordinates of its nodes are not constraint to a certain interval in the angular space. This example also allows us to understand why, as we will show, the metric cluster is more effective in shielding cooperators from defectors (akin to spatial selection) than the connected cluster. This is due to the different abundance of intercluster links, i.e., links that connect a cooperator and a defector, which we highlight in Fig. 3. There are 125 of such links in the example of the connected cluster and only 53 for the metric cluster, where the intercluster links mainly occur at the border of the metric cluster (this effect is more pronounced for larger networks). We analyze the abundance of intercluster links in detail later.

### Metric clusters can be more effective than hubs

Let us now consider two empirical networks, the Internet Ipv6 topology, which has N = 5162 nodes, a degree distribution with power-law exponent γ = 2.1, average degree $$\bar k = 5.2$$, and a mean local clustering coefficient of $$\bar c = 0.22$$ and the arXiv collaboration network, which has 1905 nodes, mean degree $$\left\langle k \right\rangle$$ = 4.6, mean local clustering coefficient $$\bar c = 0.66$$, and a power-law degree exponent γ = 3.9. To address the question of whether spatial clusters or the hubs of a network are more efficient at sustaining cooperation, we use the initial conditions as a proxy for possible control mechanisms26, 29,30,31. Specifically, we distribute the initial cooperators (always c(0) = 0.5) in the system as follows: first, we randomly assign 50% of the nodes as cooperators; second, we assign the same number of cooperators preferentially to the hubs of the system, i.e., we select nodes proportional to their degree; third, we assign the same number of cooperators into a metric cluster in the similarity space (see Methods). The first strategy serves as a null model, the second mimics the potential of the hubs to drive the system toward cooperation, while the third strategy serves as a proxy for the ability of metric clusters of cooperators to survive.

Figure 4a shows the result for the Internet IPv6 topology, where we show the regions in the TS plane, in which the degree of final cooperation exceeds an arbitrarily chosen threshold value of 0.3. In the blue area, this is always the case. In the green region, this holds if the system began with cooperative hubs or a metric cluster. In the yellow region, the cooperative threshold is only exceeded if the system began with cooperative hubs (see Supplementary Fig. 2 for details). This behavior is significantly different in the case of the arXiv collaboration network (Fig. 4b). In contrast to the previous case, there is no region where only initially cooperative hubs allow for sustained cooperation. In the gray region, however, final cooperation only exceeds the threshold value if the system was started with cooperators forming a metric cluster. Hence, whereas in the Internet IPv6 topology hubs can drive the system toward cooperation, in the case of the arXiv network metric clusters are more efficient at sustaining cooperation than the most connected nodes. We observe a similar behavior using synthetic scale-free networks with different mean local clustering coefficients and power-law exponents. Figure 4c shows a similar behavior to that of the Internet (i.e., the hubs are more efficient than metric clusters), whereby the networks were generated with a power-law exponent γ = 2.4 and mean local clustering coefficient $$\bar c = 0.5$$ (here, cooperation is sustained in none of the cases in the red region). In Fig. 4d, we find a behavior similar to the arXiv (i.e., metric clusters are more efficient than the hubs), where we have generated synthetic networks with power-law exponent γ = 2.9 and clustering $$\bar c = 0.6$$. To conclude, in very heterogeneous networks, hubs are efficient at driving the system towards cooperation, whereas in less heterogeneous—but including scale-free—networks, metric clusters are more efficient.

To investigate this effect in detail, let us now consider the prisoner’s dilemma game, in particular parameters S = −0.5 and T = 1.5 in the payoff matrix from Eq. (1), which is widely used as a proxy for real social dilemma situations. We vary the network topology using the model mentioned earlier. In particular, we tune the heterogeneity in terms of the power-law exponent γ and the mean local clustering coefficient, $$\bar c$$, which is a measure of the strength of the underlying metric structure21. We consider the different strategies of allocating the initial cooperators discussed before.

The combination of the initial conditions and the network topology yields particularly interesting insights. If the initial cooperators are distributed randomly, final cooperation is always very low for the chosen parameters T and S (Fig. 5a). We find the same result (Supplementary Fig. 5) if the initial cooperators are assigned into a connected (i.e., unique network18) cluster (see Methods). However, if the initial cooperators are distributed among the hubs of the system and the network is sufficiently heterogeneous, they are able to drive the system to a highly cooperative state (see blue region Fig. 5b, and Supplementary Movie 2). Large mean local clustering $$\bar c_{}^{}$$, which implies a strong metric structure, adds to this effect (cf. green region in Fig. 5d, e), in agreement with ref. 32. Importantly, if the network is not sufficiently heterogeneous, but still scale-free, the hubs lose their ability to control the system and defection eventually prevails (red region in Fig. 5b, Supplementary Movie 3). In contrast, if we begin with the initial cooperators clustered in the metric space, this will allow for sustained cooperation even in scale-free networks, but only if the metric structure is sufficiently strong (see Fig. 5c, blue region in Fig. 5d, and Supplementary Movie 4). If the network becomes too heterogeneous, the clusters are no longer sustained (see Fig. 5f and Supplementary Movie 5).

We also investigate whether network and cluster size affect the ability of metric clusters of cooperators to survive. In Fig. 5g, we show that the final cooperation density increases with the system size and saturates to a value close to C = 0.5. For a fixed network size, cooperation decreases if we assign cooperators into a larger number of smaller clusters (see Methods), as shown in Fig. 5h. However, if plotted as a function of the absolute size of the individual clusters (which can be calculated by dividing the number of nodes by twice the number of clusters), the curves that correspond to different network sizes collapse, see Fig. 5i. This suggests that the survival of a metric cluster of cooperators is directly related to its absolute size.

Finally, we can formulate approximate conditions for the survival of cooperating metric clusters. Their survival is favored if they are large enough, i.e., their size is n c  > 103 (Fig. 5g), if the mean local clustering is high enough, i.e., $$\bar c >0.5$$ (Fig. 5f), and if the network is not too heterogeneous, i.e., γ > 2.5.

### Intercluster links explains the survival of metric clusters

The survival of metric clusters of cooperators can be understood as analogous to spatial selection in Euclidean space in lattice topologies. In this case, clusters of cooperators survive because they are shielded from surrounding defectors, such that the interactions between cooperators and defectors only occur at the border of the clusters. Similarly, in heterogeneous networks, metric clusters survive because they are shielded from surrounding defectors and their spatial organization reduces the number of interactions between cooperating and defecting individuals. For larger clusters, the relative surface area of the border in contact with adjacent defectors decreases, which shields them more effectively and hence explains why they are more likely to survive (Fig. 6a). For a given size, two different mechanisms determine the number of links between spatially clustered cooperators and defectors. Firstly, the greater the degree of heterogeneity, the larger the number of hubs, i.e., high degree nodes. These nodes are connected to many other nodes, and therefore form long-range connections in the metric representation, which are likely to connect cooperators and defectors. This is the reason why more heterogeneity hinders the survival of metric clusters (Fig. 6b). For a fixed level of heterogeneity, increasing the mean local clustering coefficient will reduce the temperature $$\bar T$$, which reduces the amount of long-range connections due to randomness, cf. Fig. 1a, b. Therefore, a higher degree of mean local clustering reduces the number of intercluster links, which in turn favors the survival of metric clusters as explained before (Fig. 6b).

## Discussion

Structured populations play an important role in the evolution of cooperation in social dilemmas. Real contact networks are heterogeneous (often scale-free) and exhibit a high mean local clustering coefficient. The latter implies the existence of an underlying geometry21. Specifically, real heterogeneous networks can be embedded into hyperbolic space comprising a popularity (radial) dimension and a similarity (angular) dimension.

We have shown that this underlying metric space plays an important role in the evolution of cooperation in heterogeneous contact networks. Specifically, evolutionary dynamics lead to the formation of clusters of cooperators in the angular dimension of the underlying metric space, akin to spatial selection in Euclidean space13, 14. This behavior can be understood in terms of the fraction of intercluster links that determines how well metric clusters of cooperators are shielded from surrounding defectors. Depending on the power-law exponent γ of the degree distribution and the mean local clustering coefficient $$\bar c$$ (which is proportional to the strength of the metric structure), metric clusters can be more efficient at sustaining cooperation than the most connected nodes, which is the case in the arXiv collaboration network. Only when the network is very heterogeneous, such as in the case of the Internet IPv6 topology, are hubs more effective at promoting cooperation. We have shown that if cooperators are clustered in the metric space, heterogeneity can hinder cooperation in the prisoner’s dilemma. Finally, one could argue that such a configuration is more realistic than random initial conditions, as for example the nodes in the Internet network that correspond to the same countries are naturally clustered in the metric space (see ref. 25, and different countries adopt different attitudes towards mitigating climate change33.

Our findings reveal that heterogeneity does not always favor cooperation in evolutionary games on structured populations, but can even have the opposite effect, thus complementing existing studies about the impact of heterogeneity of realistic contact networks. Furthermore, our framework unifies the description of spatial effects and the heterogeneity of contact networks. This framework can be applied to different games and extended to multiplex networks, opening promising future lines of research.

## Methods

### Evolutionary game dynamics

In the evolutionary game dynamics considered here, individuals play strategic games with their contacts where, for instance, they have two strategic choices: they can either cooperate (C) or defect (D). The payoff of each two-player game is then described by the payoff matrix Parameters T and S define different games6. T < 1 and S > 0 defines the “harmony” game, T < 1 and S < 0 corresponds to the “stag hunt” game, T > 1 and S < 0 yields the “prisoner’s dilemma”, and finally for T > 1 and S > 0 we obtain the “snowdrift” game.

One round of the game consists of each individual playing one game with each of her neighbors in the network of contacts. For each game, nodes collect payoffs given by Eq. (1), which depend on the strategies of the involved players. Here we consider the evolution of the system to be governed by imitation dynamics34,35,36 (Fig. 1c), reflecting that individuals tend to adopt the strategy of more successful neighbors. After each round of the game (synchronous updates) each node i chooses one neighbor j at random and copies her strategy with probability P ij , specified by the Fermi–Dirac distribution15, 37, 38

$$P_{i \leftarrow j} = \frac{1}{{1 + {\mathrm{e}}^{ - \left( {\pi _j - \pi _i} \right)/K}}},$$
(2)

motivated by maximum entropy principles in Glauber-like dynamics34, 39. π i and π j measure the payoffs of nodes i and j, while K denotes the irrationality of the players, which we set to 0.5. After all nodes have updated their strategy simultaneously, we reset all payoffs.

In this contribution, games are played only on the giant connected component (GCC) of the network of contacts.

### Complex networks embedded into underlying metric spaces

Metric spaces underlying complex networks provide a fundamental explanation of their observed topologies23, 24. In the class of models used here, each node i is mapped into the hyperbolic disc where it is represented by the polar coordinates r i , θ i . These coordinates abstract the popularity and similarity of nodes24. The radial coordinate r i is related to the expected degree of node i and therefore abstracts its popularity. More popular nodes are located closer to the center of the disc (lower radial coordinate). The angular distance between nodes i and j, $${\mathrm{\Delta }}\theta _{ij} = \pi - \left| {\pi - \left| {\theta _i - \theta _j} \right|} \right|$$, is an abstract measure of their similarity. Lower distance implies higher similarity. The hyperbolic distance23

$$x_{ij} = {\mathrm{cosh}}^{ - 1}\left( {{\mathrm{cosh}}\,r_i\,{\mathrm{cosh}}\,r_j - {\mathrm{sinh}}\,r_i\,{\mathrm{sinh}}\,r_j\,{\mathrm{cos}}\,{\mathrm{\Delta }}\theta _{ij}} \right),$$
(3)

combines information about both popularity and similarity of nodes i and j, such that the connection probability for a given pair of nodes depends only on their hyperbolic distance.

To generate networks based on hidden hyperbolic space, we distribute nodes on the hyperbolic disc by assigning polar coordinates (r i , θ i ) to each node. In particular, we draw θ i from the uniform distribution $${\cal U}_{[0,2\pi )}$$ and radial coordinates r i from the distribution

$$\rho (r) = \frac{1}{2}(\gamma - 1){\mathrm{e}}^{\frac{1}{2}(\gamma - 1)(r - R)},$$
(4)

where R denotes the disc radius given by23

$$R = 2\,{\mathrm{ln}}\left[ {\frac{{2TN}}{{\bar k\,{\mathrm{sin}}\,\bar T\pi }}\left( {\frac{{\gamma - 1}}{{\gamma - 2}}} \right)^2} \right]{\kern 1pt} ,$$
(5)

where N denotes the number of nodes, γ is the power-law exponent of the degree distribution, and T denotes the temperature. Finally, we connect pairs of nodes i and j with probability p(x ij ), which depends exclusively on the hyperbolic distance x ij between nodes i and j. The connection probability is given by the Fermi–Dirac distribution

$$p\left( {x_{ij}} \right) = \frac{1}{{1 + {\mathrm{e}}^{\frac{1}{{2\bar T}}\left( {x_{ij} - R} \right)}}},$$
(6)

where the aforementioned temperature $$\bar T$$ controls the strength of the metric structure and the level of mean local clustering, $$\bar c$$. This is illustrated in Fig. 1a, b.

Finally, given a real network, coordinates of the nodes can be inferred using maximum likelihood estimation techniques40, 41. This enables us to identify the set of coordinates that maximize the probability that the observed real-world network was generated using the described model. The inferred hyperbolic maps have proven to be very accurate in the case of scale-free, clustered networks25, 42, 43.

### Mean local clustering and relation to the spatial structure

The local clustering coefficient of node i is defined as44

$$c_i = \frac{{2 \cdot {\mathrm{Number}}\,{\mathrm{of}}\,{\mathrm{closed}}\,{\mathrm{triangles}}\,i\,{\mathrm{participates}}\,{\mathrm{in}}}}{{k_i\left( {k_i - 1} \right)}},$$
(7)

where k i denotes the degree of node i. The maximal number of closed triangles a node with degree k i can participate in is k i (k i  − 1)/2. The mean local clustering coefficient of a given network is then the average of c i over all nodes with k > 1 (nodes with k = 1 cannot participate in any triangles).

In the framework introduced in the previous section, a low temperature $$\bar T$$ implies a high mean local clustering, which is the consequence of the triangle inequality in the underlying metric space (Fig. 1a). A high temperature, however, induces more randomness in the form of long-range connections (see Eq. (6)), which reduces the mean local clustering coefficient (Fig. 1b). See ref. 23 for further details.

### KS statistic

The KS statistic28, which we denote as $$\bar \rho$$, is defined as the maximum absolute difference between the values of two cumulative distributions. We are interested in measuring the difference between the distribution of cooperators in the angular space, c(θ), whose cumulative distribution is given by $$C(\theta ) = {\int}_0^\theta {\mathrm{d}}\theta {\prime}\, c\left( {\theta {\prime}} \right)$$, and the uniform distribution. Then, the KS statistic is given by

$$\rho _C = \mathop {{{\mathrm{max}}}}\limits_{\theta \in \left\{ {0,2\pi } \right\}} \left| {C(\theta ) - \frac{\theta }{{2\pi }}} \right|$$
(8)

and analogously

$$\rho _D = \mathop {{{\mathrm{max}}}}\limits_{\theta \in \left\{ {0,2\pi } \right\}} \left| {D(\theta ) - \frac{\theta }{{2\pi }}} \right|,$$
(9)

where D(θ) = θ − C(θ) denotes the cumulative distribution of defectors in the angular space. Finally, we define

$$\bar \rho = c\rho _C + \left( {1 - c} \right)\rho _D{\kern 1pt} ,$$
(10)

where c denotes the density of cooperators at the current timestep. Note that here we omitted the time dependency.

### Assignment of initial cooperators

In this contribution, we always start with an initial cooperation density of C(0) = 0.5. However, the distribution of initial cooperators in the network can be different. In particular, we distinguish between the following procedures.

Random assignment: Each node is initialized as a cooperator with 50% probability and as a defector otherwise.

Hubs: We preferentially assign hubs as initial cooperators. To this end, we assign N/2 cooperators which we select proportional to their degree, i.e., p c (k) k. N denotes total number of nodes in the network.

Metric cluster: We sort all nodes by their angular coordinate θ, and assign the first N/2 nodes as cooperators.

Multiple metric clusters: We again sort all nodes by their angular coordinate θ. We now fix a number of distinct clusters, n c , and assign the first N/(2n c ) nodes as cooperators, the second N/(2n c ) nodes as defectors, the third N/(2n c ) as cooperators and so on. See Supplementary Fig. 6 for an explicit example.

Connected cluster: We assign N/2 nodes into a connected cluster, or unique network cluster18. To this end, we start from the initial graph and randomly remove nodes until the size of the giant connected component (GCC) reaches N/2. The nodes that are now in the GCC are assigned as cooperators in the original graph, and the remaining N/2 nodes are assigned as defectors. This procedure ensures that the initial cooperators form a unique connected cluster. Note that a network cluster in general is not the same as a metric cluster. Instead of N/2, we can use any size of the connected cluster, for example in Fig. 3 we used N/4.

### Empirical networks

The arXiv data are taken from ref. 45 and contains co-authorship networks from the free scientific repository arXiv. The nodes are authors that are connected if they have co-authored a paper. In arXiv, each paper is assigned to one or more relevant categories. The data only cover papers containing the word “networks” in the title or abstract from different categories up to May 2014. Here we consider the category “Molecular Networks” (q-bio.MN). The network has ~1905 nodes, mean degree $$\left\langle k \right\rangle = 4.6$$, clustering coefficient $$\bar c = 0.66$$, and a power-law degree exponent γ = 3.9.

The IPv6 Autonomous Systems (AS) Internet topology was extracted from the data collected by the Archipelago active measurement infrastructure (ARK) developed by CAIDA46. The connections in each topology are not physical but logical, representing AS relationships. An AS is a part of the Internet infrastructure administrated by a single company or organization. Pairs of ASs peer to exchange traffic. These peering relationships in the AS topology are represented as links between AS nodes. CAIDA’s IPv6 data sets provide regular snapshots of AS links derived from ongoing traceroute-based IP-level topology measurements (data sets are available at http://www.caida.org/data/active/ipv4_routed_topology_aslinks_dataset.xml and https://www.caida.org/data/active/ipv6_allpref_topology_dataset.xml). The considered topology was constructed by merging the AS link snapshots during the first 15 days of January 2015, which are provided at http://data.caida.org/datasets/topology/ark/ipv6/as-links/2015/01/ and http://data.caida.org/datasets/topology/ark/ipv4/as-links/. The network consists of N = 5162 nodes, has a power law degree distribution with exponent γ = 2.1, average node degree $$\bar k = 5.2$$, and average clustering $$\bar c_2 = 0.22$$.

The hyperbolic maps for both data sets have been taken from ref. 43.

Supplementary Figure 2 shows the final density of cooperators for both networks and for the different allocation strategies described in the main text.

### Data availability

The empirical data sets as well as an implementation of the model networks used in this study have been made available at https://figshare.com/articles/DataAndModel_zip/4817947. An implementation of the technique to construct hyperbolic maps for real networks40, 41 is publicly available at https://bitbucket.org/dk-lab/2015_code_hypermap. Any additional data that support the findings of this study are available from the corresponding author upon reasonable request.