The small-world phenomenon has fascinated popular culture and science for decades. Discovered in the realm of social sciences during the 1960s, it arises from the observation that any two persons in the world are connected through a short chain of social ties1. Since then many real networks have been found to be small-world as well2,3,4, from natural to man-made systems. But, how small is a small-world network and how does it compare to others? In the physical world we evaluate and compare the size of objects by contrasting them to a common reference, usually a standard metric system defined and agreed by the community. In the case of complex networks the difference is that every network constitutes its own metric space. Thus, the question of whether a network is smaller or larger than another implies the comparison of two different spaces with each other, rather than the more familiar situation in which two objects are contrasted within the space they live.

The quantification of the small-world property relies on the computation of the average pathlength—the average graph distance between all pairs of nodes. As it happens for any graph metric, its outcome depends on the number of nodes and links of the network under study. Consider two empirical networks. \({G}_{1}\) is a small social network, e.g., a local sports club of \({N}_{1}=100\) members. A link between two members implies they are friends. \({G}_{2}\) is an online social network with ten million users (\({N}_{2}=1{0}^{7}\)) where two profiles are connected if users follow each other. If we found that the average pathlength \({l}_{1}\) of \({G}_{1}\) is smaller than the length \({l}_{2}\) of \({G}_{2}\), we would not be able to conclude that the internal topology of the local sports-club is shorter, or more efficient, than the structure of the large online network. The observation that \({l}_{1}\ <\ {l}_{2}\) could be a trivial consequence of the fact that \({N}_{1}\ll {N}_{2}\). In order to fully interpret this result we need to disentangle the contribution of the network’s internal architecture to the pathlength from the incidental influence contributed by the number of nodes and links.

In practice, the typical strategy seen in the literature to deal with this problem consists in comparing empirical networks to well-known graph models, e.g., random graphs, scale-free networks and regular lattices2,5,6,7,8. It shall be emphasised that these architectures represent different null-models, generated upon particular hypotheses and thus useful to answer a variety of questions we may have about the data. However, their role as absolute references is restricted since they are not representative of the limits that network metrics, such as pathlength and efficiency, can take\(\tilde{L}=N\) arcs, all pointing in the same orientation. Finally, a complete graph is the network in which all nodes are connected to each other, thus containing \({L}_{o}=\frac{1}{2}N(N-1)\) edges or \({\tilde{L}}_{o}=N(N-1)\)-directed arcs. The average pathlength of a complete graph is \({l}_{o}=1\), the shortest of all networks.

Fig. 1
figure 1

Construction of ultra-short and ultra-long (di)graphs. Star graphs, path graphs, directed rings and complete graphs serve as the starting references to construct (di)graphs of arbitrary density with extremal average pathlength. ac Procedures to build ultra-short and ultra-long graphs, both connected and disconnected. Edge colour denotes the order of edge addition. Red edges are the last added and green links the ones in the previous steps. dh Generation of directed graphs with extremal pathlength or efficiency. These cases are often non-Markovian and reveal novel structures. d In the sparse regime ultra-short digraphs are characterised by a collection of directed cycles converging at a single hub. We name these flower digraphs. Every arc added leads to a flower digraph with an additional “petal”. e Although several configurations may lead to digraphs with longest pathlength, we introduce here an algorithmic approximation to the upper bound: \(M\)-backwards subgraphs. f Up to three different digraph configurations compete for largest efficiency. g The winner depends on network density. Finally, h digraphs with smallest efficiency are achieved by constructing the densest directed acyclic graphs possible, to minimise the contribution of cycles to the path structure of the network

US and UL graphs of arbitrary \(L\) can be achieved by adding edges to star and path graphs, respectively, Figs. 1a–c. In the case of digraphs, both US and UL configurations are obtained by adding arcs to a directed ring, Figs. 1d–h. The precise order of link addition differs from case to case. Two findings deserve a special mention. (1) US and UL graphs can be generated adding edges one-by-one to the initial configurations, Fig. 1a, b, but construction of extremal digraphs is often non-Markovian. That is, an US or an UL digraph with \(\tilde{L}+1\) arcs cannot always be achieved by adding one arc to the extremal digraph with \(\tilde{L}\) arcs. For example, Fig. 1d shows that the digraphs with shortest pathlength initially transition from a directed ring onto a star graph following unique configurations we named flower digraphs. (2) For a given size and number of links, all configurations with diameter \({\rm{diam}}(G)=2\) have exactly the same pathlength9,10,12 and they are US, regardless of how their links are internally arranged. Their pathlength is \(l=2-\rho\), where \(\rho\) is the link density. See the US graph theorem (Theorems 1 and 4) in Supplementary Notes 1 and 2.

When studying large networks it is common to find that these are sparse and fragmented into many components. While the pathlength in these cases is infinite, these networks can still be characterised by their efficiency, which remains a finite quantity allowing to zoom into the sparse regime. We remind that the global efficiency \(E\) of a network is defined as the average of the inverses of the pairwise distances. Thus the contribution of disconnected pairs (with infinite distance) is null. We could identify sparse configurations [\(L\ <\ N-1\) or \(\tilde{L}\ <\ 2(N-1)\)] with the largest efficiency, whose efficiency transitions from zero (for an empty network) to that of a star graph. In the case of graphs, Fig. 1a, there is a unique optimal configuration but for digraphs we found that up to three different structures compete for the largest efficiency when \(\tilde{L}\ <\ 2(N-1)\), Fig. 1f, g. See Fig. 1c, h for the graphs and digraphs with smallest possible efficiency, which equals the link density, \(E=\rho\).

The length of common network models

In the following we illustrate how knowledge of the US and UL boundaries frame the space of lengths that networks take, both empirical and models. We start by investigating the null-models which over the years have dominated the discussions on the topic of small-world networks: random graphs (Erdős–Rényi type), scale-free networks13 and ring lattices. We consider undirected and directed versions with \(N=1000\) nodes and study the whole range of densities; from empty (\(\rho =0\)) to complete (\(\rho =1\)). The results are shown in Fig. 2. Find comparative results for \(N=100\) and \(N=10,000\) in Supplementary Note 4. Shaded areas mark the values of pathlength and global efficiency that no network can achieve. Solid lines represent the ranges in which the models are connected and dashed lines correspond to the efficiency when the networks are disconnected. The location of the original building-blocks (star graphs, path graphs, directed rings and complete graphs) are also shown over the maps for reference.

Fig. 2
figure 2

Pathlength and efficiency of characteristic network models. Ring lattices (red), random (Erdős–Rényi type, green) and scale-free13 graphs (blue) of \(N=1000\) nodes, plotted together with the corresponding upper and lower boundaries ultra-long (yellow) and ultra short (grey). Shaded areas mark values of pathlength and efficiency that no (di)graph of the same size can achieve. a The average pathlength of the three models decay towards the ultra-short limit at sufficiently large density. b Same as panel (a) with density re-scaled for visualisation. c Global efficiency of the network models. The lower boundary (ultra-long) is represented by two lines: a dashed line representing the efficiency of disconnected graphs \({E}_{dUL}\approx \rho\) and a solid line for connected graphs. d Same as panel (c) with density re-scaled for visualisation. The efficiency of random and scale-free graphs undergoes a transition from ultra-long to ultra-short centered at their percolation thresholds. e Pathlength of random and scale-free digraphs. In this case, the two boundaries emerge from the same point corresponding to a directed ring (open circle). f Efficiency of random and scale-free digraphs. Curves for random and scale-free networks are averages over 1000 realisations. Dashed lines represent ranges of density for which the models are disconnected and solid lines represent (di)graphs which are connected. Results for sizes \(N=100\) and \(10,000\) are shown in Supplementary Note 4

The pathlength of random, scale-free and ring networks decays with density, as expected, with the three eventually converging onto the lower boundary and becoming US, Fig. 2a, b. But, the decay rates differ across models. Scale-free networks are always shorter than random graphs in the sparser regime, where the length of both models is well above the lower boundary. However, the two models converge simultaneously onto the US limit at \(\rho \approx 0.08\). On the other hand, the ring lattices decay much slower and only becomes US at \(\rho \approx 0.5\).

Figure 2c, d reproduces the same results in terms of efficiency. An advantage of efficiency is that it always takes a finite value, from zero to one, regardless of whether a network is connected or not. Zooming into the sparser regime, we observe that the efficiency of both random (\({E}_{r}\)) and scale-free (\({E}_{SF}\)) graphs undergoes a transition, shifting from the UL to the US boundary, Fig. 2d. They are nearly identical except for a narrow regime in between \(\rho \in (4\ \times \ 1{0}^{-4},2\ \times \ 1{0}^{-3})\). Here, \({E}_{SF}\) grows earlier than \({E}_{r}\), reaching a peak difference of \({E}_{SF}\approx 5\times {E}_{r}\) at \(\rho =1{0}^{-3}\). The reason for this is that SF graphs percolate earlier than random graphs14. Indeed, the onset of a giant component in random graphs of size \(N=1000\) happens at \(\rho \approx 1{0}^{-3}\).

The results for the directed versions of the random and scale-free networks, Fig. 2e, f, are very similar. The main difference is that when \(\tilde{L}=N\) both the upper and the lower boundaries are born from the same point corresponding to a directed ring, Fig. 2e.

Length and global efficiency of empirical networks

We now elucidate how the knowledge of the boundaries allows us to interpret the length of real networks faithfully. First, we will illustrate how different references may give rise to subjective interpretations. Then, we will show how the boundaries help framing both empirical and model networks into a unified representation.

Given two networks \({G}_{1}\) and \({G}_{2}\) with pathlength \({l}_{1}\ <\ {l}_{2}\) (the absolute values), we could affirm that \({G}_{1}\) is shorter than \({G}_{2}\). But, if \({G}_{2}\) is bigger (\({N}_{1}\ <\ {N}_{2}\)) then the fact that \({l}_{1}\ <\ {l}_{2}\) does not necessarily imply that the topology of \({G}_{1}\) is more efficient than the topology of \({G}_{2}\). An approach commonly followed in the literature to face this problem consists in comparing networks \({G}_{1}\) and \({G}_{2}\) with well-known network models, or null-models. For example, random graphs (Erdős–Rényi) and ring lattices are typically employed as the references to characterise the “small-worldness” of complex networks. In some cases, the relative pathlength \(l^{\prime} =l/{l}_{r}\), is used which considers the length \({l}_{r}\) of random graphs as the lower boundary5. This measure takes \(l^{\prime} =1\) when the length of the network matches that of random graphs. In other cases, a two-point normalisation using ring lattices as the upper boundary6,7 was proposed, \(l^{\prime} =(l-{l}_{r})/({l}_{latt}-{l}_{r})\). Here, \(l^{\prime} =0\) if the length of the real network equals that of random graphs (the lower boundary) and \(l^{\prime} =1\) if it matches the length of ring lattices (the upper boundary). Considering the US and UL boundaries, one could also propose the following re-scaling

$$l^{\prime} =\frac{l}{{l}_{US}}.$$
(1)
$$l^{\prime} =\frac{l-{l}_{US}}{{l}_{UL}-{l}_{US}}.$$
(2)

At this point, it shall be stressed that the use of relative metrics may lead to biased interpretations, depending on the question(s) we are asking about the data. Relative pathlengths such as \(l^{\prime} =l/{l}_{r}\) and \(l^{\prime} =l/{l}_{latt}\) are conceptually different from the ones in Eqs. (1) and (2) because \({l}_{r}\) and \({l}_{latt}\) are expectation values associated to given null-models while \({l}_{US}\) and \({l}_{UL}\) are actual limits. Thus, they are meant to answer different questions. On the one hand, null-models are constructed upon particular sets of constraints and following generative assumptions on the rules governing how nodes link with each other. The role of expectation values is thus to test whether those hypotheses explain the pathlength observed in the real networks. On the other hand, limits correspond to the extremal values (di)graphs could take and are independent of generative assumptions. The reader should keep in mind that here, our intention is neither to identify the key topological factors that “explain” the pathlength observed in real networks nor to model the real networks themselves. Our goal is to address the question “how short or how long is a given network?” This allows us to position network models in the space of reachable pathlength and to compare these models with potentially different numbers of nodes and links.

For practical illustration, we study a set of empirical datasets from three different domains: neural and cortical connectomes, social networks and transportation systems, see Table 1. These examples represent a small but diverse set of real networks with sizes ranging from \(N=34\) to \(4941\) and densities ranging from \(\rho \approx 1{0}^{-4}\) to \(0.330\). First, we show that the ranking of these networks with respect to pathlength is very much altered depending on the relative reference chosen, Fig. 3. According to the absolute pathlength, Fig. 3a, cortical and neural connectomes tend to be shorter than social and transportation networks. The network of prison inmates is directed and weakly connected, therefore it has an infinite pathlength. See Supplementary Note 5 for the results presented in terms of global efficiency. We could now ask whether these observations are a trivial consequence of the different sizes of those networks. For that, we consider the relative pathlength \(l^{\prime} =l\ /\ N\), Fig. 3b. In this case, the ranking changes considerably. The short length of the cortico-cortical connectomes seems to be partly explained by their small size (\(N\ <\ 100\)).

Table 1 Characteristics of the sample real networks investigated: For illustrative purposes we analyse twelve networks from three different domains: neural, social and transportation. Networks marked with and asterisk (\({}^{* }\)) are directed
Fig. 3
figure 3

Comparison of absolute and relative pathlength for selected neural, social and transportation networks. a Absolute average pathlength of the empirical networks, bf different relative pathlength definitions. b Relative to network size \(N\), c relative to equivalent random graphs, d relative to the pathlength to the ultra-short boundary. e, f Two-point normalisations considering random graphs and ring lattices as benchmarks (e), and relative to the ultra-short and ultra-long boundaries (f). Red crosses indicated cases for which all random graphs generated as benchmark were disconnected and had thus an infinite pathlength. The Prison social network is weakly connected and can thus only be studied by characterising efficiency, see Supplementary Note 5

When considering random graphs as the reference, Fig. 3c, we find that all the networks take relative values \(l^{\prime} \approx 1\); with the neural networks, the Zachary karate club and the airports network being the closest to random graphs. With these results at hand we may tend to believe that, e.g., the airport transportation network is shorter than the dolphins social network. This interpretation is only part of the picture because \({l}_{r}\) is an expectation value. Here, \(l^{\prime}\) provides a ranking of the networks whose pathlength is better explained by the generative assumptions of random graphs. If the US limit is taken as reference, a different scenario is found, Fig. 3d. In this case, the cortical networks (cat, macaque and human) lie marginally above \(l^{\prime} =1\), meaning that they are practically US. The dolphins and the facebook circles are twice as long as the lower boundary and the transportation networks deviate even further. The comparison to random graphs was not possible for three transportation networks (London transportation, Chicago transportation and the U.S. power grid) because their densities lie below the percolation threshold for Erdős–Rényi graphs and thus no connected graphs could be constructed with the same \(N\) and \(L\). Calculated in terms of global efficiency, this comparison shows that these three networks are less efficient than random graphs and lie notably far from the optimal, see Supplementary Note 5. Notice that transportation networks, in reality, are embedded in space and are nearly planar. The planarity helps sparse networks to be connected15, while they would easily be disconnected if this constraint were ignored. However, here we are discarding any constraints besides \(N\) and \(L\) whether they concern internal features (e.g., the degree distribution) or external (e.g., spatial embedding), and focus solely on the theoretical limits the pathlength and efficiency can take.

Figure 3e shows the two-point relative pathlengths when both random graphs and ring-lattices are taken as references. With these results the Zachary Karate Club and the airports network would appear to be shorter than the brain connectomes, the collaboration network of jazz musicians and the dolphin’s network. Since \({l}_{r}\) and \({l}_{latt}\) are expectation values, the results should be seen as which of the two null-models, random graphs or ring-lattices, better explains the length of each real network. Finally, considering the US and the UL boundaries as references, Fig. 3f, it becomes clear that all the networks are closer to the US boundary than to the UL.

So far, we have evidenced that the use of relative metrics to rank networks according to their length may lead to biased interpretations because the outcome depends on whether the reference is a null-model or a limit. Therefore, a more informative solution than relying on relative metrics is to display all the relevant results, both for real networks and for null-models, into a unified representation. Figure 4 shows the global efficiency of the thirteen empirical networks (+), together with their corresponding US (grey bars) and UL (gold bars) boundaries, and the expectation values for equivalent random graphs (blue lines) and ring lattices (red lines). This representation elucidates the results reported in Fig. 3c–f. First, the space of accessible efficiencies (delimited in between the lower and the upper boundaries) differs from case to case, depending on the size and density of each network. Second, the position that both real networks and null-models take within this space is revealed. In the case of the three brain connectomes (cat, macaque and human) their equivalent random graphs match the US boundary. Thus comparing these networks to random graphs is the same as comparing them to the lower limit. However, in sparser networks this is no longer the case. For example, the efficiency of the neural network of the Caenorhabditis elegans is close to that of random graphs, but both values depart from the US boundary. In this case, the network is far from ring lattices (red lines) and from the UL boundary. The opposite is found for transportation networks: their global efficiency and the efficiency of corresponding random graphs lie closer to the UL boundary than to the US.

Fig. 4
figure 4

Comparison of global efficiency for selected neural, social and transportation networks. The global efficiency of the thirteen empirical networks (+) is shown together with their ultra-short and ultra-long boundaries. The span of the boundaries very much differs from case to case because of the different sizes and densities of the networks studied. For the denser networks (e.g., cortical connectomes) the efficiency of random graphs (blue lines) lie almost on top of the largest possible efficiency (ultra-short boundary). On the contrary, for the sparser networks (e.g., the transportation systems) the efficiency of random graphs very much divert from ultra-short

In summary, the synoptic representation in Fig. 4 tells us that: (1) The pathlength (efficiency) of empirical networks is usually comparable to the length of random graphs; meaning that the random connectivity hypothesis partly explains the empirical values. But (2) the position networks take with respect to the limits very much differs from case to case, exposing how close each network—real and models—lie from the optimal efficiency or from the worst-case scenario. In future practical studies, Fig. 4 can be complemented with the results from other null-models, each accounting for specific sets of constraints, e.g., conserving the degree distribution or considering the limitations imposed by the spatial embedding. The expectation value calculated for each null-model will add one datapoint per network and thus allow to visualise the contribution of every set of constraints. Here, we restricted to random graphs and ring lattices for the illustrative purposes.