Introduction

Dynamic collective behaviors are commonly observed in a host of technological and natural systems. The emergence of spatiotemporal order at the group level has been observed in many biological systems1,2,3—insect colonies, fish schooling, bird flocking, amoebae aggregating, bacteria swarming, in many human activities4,5—pedestrian and automobile traffic and in the artificial world with robotic swarm systems6,7 and sensor networks8,9. These dynamic collective behaviors are believed to emerge from simple local interaction rules governing the dynamics of individual agents10,11. They imply nonindependent individual decisions through local information transfer between group members mediated by one or more signaling mechanisms. One of the most prevalent collective decision-making processes consists in achieving a consensus decision—consensus means the convergence to a common state asymptotically or in a finite time among all group members through local interactions.

Until recently, the vast majority of dynamic models of collective behaviors of mobile agents relied on the basic assumption that each individual's neighborhood of interaction was based on a metric distance corresponding to the fixed range of its sensory capabilities12,13,14,15,16,17,18,19. A recent landmark study from the STARFLAG group imaged and tracked wild flocks of starlings numbering in the thousands and revealed that the neighborhood of interaction actually depends on a topological distance2,3. More precisely, Ballerini et al.2 discovered that each bird interacts on average with a fixed number of nearest neighbors (six to eight). A few very recent studies20,21,22 are starting to offer initial explanations as for why the starlings topologically interact with their seven nearest neighbors. Camperi et al.20 used a self-propelled particles (SPPs) model13 based on the extended formulation by Grégoire et al.23, which they themselves extended to three dimensions. Some results from the STARFLAG experiments were fed back into the model through the parameters controlling the neighborhood of interaction, allowing Camperi et al.20 to find that topological models are more stable than metric ones and that the minimal number of interacting neighbors needed to achieve fully stable cohesion in a spatially balanced model is compatible with the observed value of six to seven. Young et al.21 adopted a system-theoretic approach to analyze some empirical results from the STARFLAG experiments and found that for the range of flocks observed the optimal number of neighbors does not depend on the size of a flock. Instead, Young et al.21 have shown that both the optimal number of neighbors and the peak value of robustness per neighbor depend on the shape of the flock. Komareji & Bouffanais22 used a network-theoretic approach to study the dynamics of the signaling network of interaction between agents and found that a minimum number k* of topologically interacting nearest neighbors is necessary to maintain the connectedness of the signaling network as well as its controllability. Komareji & Bouffanais22 also established that k* does depend on the number of individuals forming the collective, albeit moderately and for group sizes in the thousands, the value of k* is in relatively good agreement with the empirical observations from the STARFLAG experiments.

Here, we address the question of what is the connection between the number k of topologically interacting neighbors tracked by each individual in the swarm and the emergence of consensus. Using network- and graph-theoretic approaches combined with the linear dynamical model by Komareji & Bouffanais22, we prove mathematically that consensus is always attainable in the absence of uncertainty due to environmental noise sources. We also establish analytically the exponential convergence of the system and find the expression of the parameter controlling the rate of convergence to consensus thereby allowing us to define a speed to consensus. This quantity is proved to be strictly increasing with the number k of topologically interacting neighbors. Furthermore, a numerical study of the variations of both speed to consensus and time to consensus with respect to k and for different swarm population sizes—with and without uncertainty due to the possible presence of noise in the signaling mechanisms—reveals that a value of k ~ 10 significantly speeds up the rate of convergence to consensus to levels very close to the optimal level corresponding to an all-to-all interaction signaling. In addition, the rate of variation of the speed to consensus and time to consensus with k are both found to be practically independent on the group size, which for typical collective behaviors ranges from a few dozens to a few thousands (in rare cases tens of thousands)11.

In summary, our analysis allows us to prove that the remarkably small number of topological neighbors (approx. 10) as compared to the swarm size—at least two orders of magnitude—may find its origins not only in obvious environmental and natural limitations, as observed in3,24, but also more fundamentally in the structural properties and dynamics of the signaling network. In particular, our study reveals for the first time that it significantly enhances the consensus reaching process, which is key to most swarming behaviors.

Results

Relationship between speed to consensus and the network dynamics

First, we investigated the swarm dynamics based on the topological dynamic model governed by Eq. (11) (See Methods) in the ideal case where noise is absent. A central point to always keep in mind is the fact that the directed swarm signaling network (SSN)—which is the information transfer channel underpinning the swarm dynamics—has a dynamics that is evolving hand in hand with the dynamics of the mobile agents in the physical space. In other words, signaling network structure and information dynamics change on the same time scale and are strongly interwoven. The SSN has been found to be a homogeneous small-world and moderately clustered network22. It is worth reminding that small-world effects have been shown to directly influence the speed to consensus; indeed fast consensus is achieved when the topology of the directed information flow possesses the small-world characteristic25,26.

The speed of convergence to consensus is classically assessed by means of the spectral properties of the graph Laplacians. Specifically, the second smallest eigenvalue of the graph Laplacians λ2—a.k.a. algebraic connectivity—quantifies that speed of convergence in the presence of a static and balanced digraph. This is for instance the approach considered by Young et al.21, where the H2 nodal robustness per neighbor was considered, as well as the consensus speed which was defined as the real part of λ2. This approach was made possible by the fact that Young et al.21 considered a fixed static sensing graph corresponding to the steady state. In the present study, we consider the full transient swarm dynamics for which the graph Laplacian of the SSN is both switching and not balanced—in general, for each agent, the indegree is different from the fixed outdegree k22, hence a more general approach is required.

Throughout the complete dynamical process, the SSN maintains a constant number of nodes and a constant number of edges. However, at each instant a certain number of link failures occurs which exactly amounts to the number of newly created ones. The rate at which those links are destroyed and created is governed by the pace of the physical dynamics of the swarm as well as the degree of alignment—or long-range synchronization. Hence, we are in the presence of a switching network for the SSN. At this point, it is crucial pondering over the precise nature of these topological switchings. Indeed, such switching events intrinsically occur at nonuniform time intervals, whenever at least one agent stop interacting with another agent—a link is knocked down—in favor of a newly closer neighbor—a new link is formed. Knowing the exact instants at which such switchings occur is not necessary to gain insight into the effects of network switching on consensus reaching. Without loss of generality, we will assume that those switching events are evenly distributed in time, meaning that tm+ 1 = tm + τ for all m, where τ is a characteristic SSN switching time scale. From the statistical physics standpoint, τ is directly related to the decorrelation time scale of the matrix of correlations between normalized velocities Cij = 〈si · sj〉 also known as directional correlation function11, where notations from27 are used. As all the agents move at the same speed v0, the decorrelation time scale is therefore strictly equivalent to the spatial decorrelation scale, which given our topological neighborhood of interaction is directly related to k27.

Consensus reaching process

Switching networks are generally modeled using a dynamic graph Gs(t) parameterized with a switching signal s(t) that takes its values in an index set 26. That is equivalent to choosing τ = 1, thereby imposing one specific choice of the unit of time of the swarm dynamics. Following that approach, let G(N, k) denote the random k-nearest neighbor digraph model representing the SSN of a group of N topologically interacting agents randomly and uniformly distributed on a unit square28,29,30. We randomly choose a sequence in G(N, k) and subsequently generate a Markovian dynamical random network G(t) such that

Note that the random character of the above Markovian dynamics reflects the fact that between two consecutive instants m − 1 and m, the interagent normalized velocity correlations matrix Cij is fully decorrelated according to the above choice of time scale.

For a symmetric matrix , we denote its spectrum in the increasing order as

Let . We want to show the following result

Theorem A

Assume that k ≥ 1. For almost all random sequencesin G(N, k), the switching system

does reach consensus. Here L(t) is the corresponding (outdegree) graph Laplacian of G(t) and.

If k ≥ 3, then the system has exponential convergence and the rate of convergence of consensus is dictated by the quantity ν (0, 1) defined by

where · is the Euclidean norm of a vector. (see Supplementary Information for a detailed proof of Theorem A).

This very general result guarantees that consensus will be reached in the absence of any environmental noise sources. It is quite clear that the speed of convergence to consensus will also be influenced by the possible presence of noise. Given the above expression of ν, the rate of convergence to consensus, or speed to consensus, can be explicitly defined as

This choice of definition can easily be understood when turning to the particular case of a static fixed and balanced graph G = L/k, for which one would get CS ~ λ2(G)26.

Influence of the number of neighbors on speed to consensus

We then turned to the investigation of the influence of the number of interacting neighbors—namely k given our k-nearest neighbors topological neighborhood of interactions—on the consensus reaching process. The following corollary shows that the rate of convergence to consensus of system (3) strictly increases with k. In our dynamical model of collective swarm behavior, the outdegree k characterizes the density of information transfer channels and the degree of connectivity of the SSN. Therefore, it is intuitively imaginable that a higher k leads to faster consensus since the connectivity of the network underpinning the dynamics of the interacting swarming agents affects profoundly the consensus capability—in general, higher degree of connectivity yields higher rate of convergence to consensus31,32,33,34.

Corollary B

Let k* be the optimal value which provides the fastest rate of convergence to consensus, i.e.,

Then k* = N − 1. Moreover, ν(k) is strictly decreasing with respect to k. (see Supplementary Information for a detailed proof of Corollary B).

The result in Corollary B, although general and remarkable, does not inform us about the exact dependence and variations of the consensus speed with respect to the number of topologically interacting agents k. To allow for a comparison between different swarm populations, we consider the normalized consensus speed

based on the highest speed to consensus—given by Corollary B—achieved with the all-to-all SSN connectivity corresponding to k = N − 1. In Fig. 1.A, we show the normalized consensus speed as a function of k for various sizes of SSNs numbering in the hundreds to 1100. Firstly, we observe that the consensus speed monotonously increases with respect to k as predicted by Corollary B. Secondly, by examining the trend of the graphs for increasing values of the swarm population N, we observe that seems to be converging as N goes to infinity. The most important fact of all is that for relatively small values of k, in the range from 3 to 10, the consensus speed varies very little with N for a given value of k but actually has a very rapid increase— is approximately tripled when going from k = 3 to 10—with the number of nearest neighbors k. This fact is much better appreciated when looking at Fig. 1.B, where the rate of variation with k of sharply decreases in the interval 3 ≤ k ≤ 10. This fact implies that edges added in the process of increasing k, say from 3 to 10, do contribute significantly to a larger algebraic connectivity of the SSN36. The result shown in Fig. 1.B is also remarkable as it reveals an apparently complete independence on N of the rate of variation of the consensus speed with k.

Figure 1
figure 1

(A) (left): normalized consensus speed vs. number of k-nearest neighbors in the topological distance. (B) (right): rate of variation of with k, , vs. k. Six different swarm populations N are considered, namely N = 100, 300, 500, 700, 900 and 1100. The normalized consensus speed was calculated for each value of k in the range 3 to N − 1 based on Eqs. (4) and (5), using a statistically ample enough sample consisting of 1000 SSNs from the G(N, k) model. The quantity is numerically obtained using a 5-point stencil differentiation of order one35.

Influence of noise on the consensus reaching process

Up to this point, our study did not account for the ubiquitous presence of noise in the environment in which the agents are evolving. To include those effects, we integrate numerically Eq. (11) (see Methods) with switching events occuring every time unit—the choice of time unit is still associated with τ = 1—following the same Markovian dynamical random network switching model for the SSN as before. At each switching event, uncorrelated noise effects are added to the N state variables θi, with the same noise level η (see Methods). We let the system evolve and observe the convergence, or not, towards a consensus value. The consensus is said to be reached when the criterion (max1 ≤ iN θi − min1 ≤ jN θj) ≤ ε is satisfied; the parameter ε characterizes the accuracy level in the consensus reaching process. We now focus on the time to consensus TC defined as the time at which the above consensus criterion is achieved. Note that TC, like CS, depends on both N and k. Similarly to what was done with CS and to allow for a comparison between different swarm populations, we consider the normalized time to consensus

We have proved that the consensus is guaranteed in the absence of noise. However, we expect this to cease to be the case in the presence of noise, especially for small values of k. It is worth noting that for the highest possible value k = N − 1, a consensus is still expected, even in the presence of noise, as each agent directly interacts with all the other individuals forming the group. For k < N − 1, we consider that the system does not reach consensus when the dynamics goes beyond 100TC(N − 1, N), which was always found to be a very long duration.

First, we investigated the noiseless case for widely different swarm population sizes numbering from hundreds to ten thousand as is shown in Fig. 2. For each data point, 1000 independent dynamics were computed, hence providing a statistically ample enough sampling. The numerical integration in time was performed using a Runge–Kutta scheme of order 437 with a time step equal to 10−3 guaranteeing an accuracy higher than the consensus reaching threshold ε = 10−4. We found little variation with the particular choice of ε in the range 0.7 to 10−5.

Figure 2
figure 2

(A) (left): average normalized time to consensus vs. number of k-nearest neighbors in the topological distance for a statistically ample enough sample consisting of 1000 repeated dynamics; the associated standard deviations are shown through the errorbars. (B) (right): rate of variation of with k, , vs. k, obtained using the average normalized time to consensus. Five different swarm populations N are considered, namely N = 100, 300, 500, 1000 and 10000. The normalized time to consensus was calculated for each value of k in the range 3 to N − 1 although not all data points are shown here to ensure graph legibility. The quantity is numerically obtained using a 5-point stencil differentiation of order one35. The consensus reaching threshold is ε = 10−4.

As a last step, we accounted for the effects of noise for two swarm sizes: N = 100 and N = 1000. Two noise levels were considered—moderate η = 0.1π and low η = 0.01π—following the study by Komareji & Bouffanais22. The results, shown in Fig. 3, still yield a decreasing time to consensus with increasing number of topological numbers k. As expected, the addition of noise introduces more variability in the results as is seen in the higher standard deviations. Interestingly, the variations of TC with k in the range 3 ≤ k ≤ 10 are much more rapid with increasing noise levels. Note that a consensus was always reached with the small swarm comprising N = 100 individuals, while some instances of non-convergence to consensus have been observed with k = 3 and 4 for the large swarm made of N = 1000 agents. This last observation can very easily explained by the disruptive effects of noise on the connectedness of the SSN for small values of k22.

Figure 3
figure 3

(A) (left): N = 100; (B) (right): N = 1000: average normalized time to consensus vs. number of k-nearest neighbors in the topological distance for a statistically ample enough sample consisting of 1000 repeated dynamics; the associated standard deviations are shown through the errorbars. Three noise levels are considered for each case: noiseless (η = 0), low (η = 0.01π) and moderate (η = 0.1π). The consensus reaching threshold is given by η + ε with ε = 10−4.

Discussion

As mentioned by Vicsek & Zafeiris in their recent review11, very few exact results about collective motion are actually available. Most relevant to the present study is the exact formulation of the convergence to consensus in a population of autonomous agents achieved by Cucker and Smale based on their own model38. Note that this powerful result was established under the strong assumption of a weighted all-to-all signaling connectivity between agents. The new exact result embodied by Theorem A relies on a much weaker assumption of limited local interactions corresponding to a SSN of the k-nearest neighbor digraph type. It is worth adding that the SSN considered in our model independently switches at each time instant with the characteristic time scale τ = 1. In other words, it follows a Markovian process of order “zero”. This simple yet tractable model represents a very first step in understanding swarm dynamics from the network science standpoint. To allow for a more realistic treatment, the SSN should mathematically be modeled as a continuous-time Markovian process, which would embody the coherent evolution of the signaling network (see Supplementary Information – Continuous-time Markovian process). The multiagent dynamical systems driven by such Markovian switching networks aimed at generating consensus behaviors (see detailed in Supplementary Information) have been extensively studied in control theory over the past few years; see e.g.39,40,41. One of the common restrictive assumptions in these works turns out to be the balance condition as used in Young et al.21. Consequently, these results do not apply here and a further thorough investigation is needed to fully understand the consensus reaching process ruled by topologically interacting neighbors under Markovian SSN.

Corollary B is quite remarkable in the sense that the rate of convergence to consensus CS is shown to strictly increase with the addition of edges (by means of increasing k) in the G(N, k) model. In general, when dealing with directed networks, this is however not the case—simply adding edges may not necessarily lead to faster convergence; only those edges contributing to a larger algebraic connectivity contribute to a faster convergence to consensus (see e.g.36).

The results associated with Fig. 1A and Fig. 1B, relating to the influence of k on the speed to consensus CS and its rate of variation with k, have a far-reaching consequence from the SSN design standpoint: adding more edges to the SSN does accelerate the convergence to consensus but this acceleration is very rapid when going from k = 3 to 10, but quickly becomes negligible when even higher values of k are being considered. Practically, adding more edges by increasing the number of topological agents with whom one is interacting is feasible but only up to a certain extent as there is always a cost associated with information exchange and also due to inherent limits in terms of signaling mechanisms, sensory and cognitive capabilities—for instance, see42 for such biological considerations with pigeons. Therefore, when accounting for the cost of adding new edges, a trade-off value kt for the number of topologically interacting agents emerges from the competition between, on the one hand, faster consensus and higher interaction cost on the other hand. This fact is in complete agreement with the results by Young et al.21 obtained using a fixed static sensing graph corresponding to the steady state.

Our numerical analysis of the dependence of the time to consensus TC with respect to the number of topological neighbors is in complete agreement with those for the consensus speed, namely: (i) for a given value of k, increases moderately with N, (ii) the time to consensus decreases very rapidly in the range 3 ≤ k ≤ 10 for all values of N as is well illustrated by the sharp increases in in that specific range of values for k, (iii) the rate of variation of the time to consensus with respect to k, , is found to be almost independent on N similarly to what was observed for .

It appears therefore that the effectiveness of the consensus reaching process is seriously impeded for the smallest values of k ~ 3, with either no convergence or a very slow one. On the other side of the spectrum, having k ~ O(N) most likely brings along overwhelming communication costs either for the living organisms or for the resources, with very limited gain in the consensus dynamics. Having the number of topological neighbors in the narrow interval k [8,12] not only speeds up the consensus reaching process significantly compared to the smallest possible values of k, but in addition, appears to be even more effective in the presence of noise.

As mentioned earlier and further detailed in the Methods section below, in the present swarming problem, consensus means the convergence to a common state asymptotically or in a finite time among all group members through local interactions. Hence, our results only apply to this particular type of consensus and not to more sophisticated emergent behaviors such as rendez-vous in space or collision avoidance for instance26. From an analytical standpoint, our specific synchronization or consensus protocol is embedded in Eqs. (10) and (11). It consists of two components: (i) the actual operation performed on the local (here topological) information gathered by a given agent—a linear averaging of the relative agents' states with respect to the actual agent receiving the information. The linearity conveniently enables us to formulate the dynamical problem as in Eq. (11) and to use the powerful results of graph theory. However, nonlinear protocols could be considered as in the case of nonlinearly coupled oscillators on complex networks43. The linearity allows for a complete and insightful analytical investigation of the consensus reaching process; (ii) the set of local neighbors formally represented by the set of indices in Eq. (10) that defines the network connectivity. Both components are embedded into the graph Laplacian L(t). It is worth adding that if one considers more complex collective collectives such as human dynamics on social networks, the more intricate nature of the local interactions gives rise to social networks with properties vastly different from the SSN considered here. Standard social networks are known to be heterogeneous scale-free networks44 while the SSN in our case is homogeneous22. Therefore, the methodology presented here can be applied to more complex social interactions but there is no doubt that the conclusions, somehow, have to be different from those obtained in our study.

In conclusion, all the results reported above shed a completely new light on the physical reasons behind the selection of a particular number of nearest neighbors locally affecting each individual's dynamics. These results are also quantitatively consistent with the number of topological neighbors reported for flocks of starlings.

Methods

In the past two decades, a wealth of swarming models have been developed and introduced. Most of them are aimed at generating consensus behaviors11,13,18,19,20,21,22,23,31,38,45,46,47,48, often in the form of group alignment or polarization. In our framework, such consensus behaviors amount to swarming that refers to a circumstance in which multiple adaptive agents—be them living creatures or artificial ones—create a certain level of spatiotemporal order characterized by one or more macro-level properties.

Following the work by Komareji & Bouffanais22, we consider a collective of N identical and topologically interacting agents moving at the same speed11. Each individual group member, at any given instant t, is assumed to be fully characterized by a given state variable ψi(t). Such a generic state variable may represent widely different characteristics depending on the nature of the group considered: e.g. employed or unemployed forager state for honey bees, kinematic variables for fish in a school, birds in a flock or robots in an artificial swarm, space available for a pedestrian on a congested sidewalk, etc. Here, the state variable simply reduces to the direction of travel and the achievement of swarm consensus therefore yields an alignment of all the agents, in other words a polarized swarm. Hence, from a formal standpoint, by reaching a consensus, we mean asymptotically converging to a one-dimensional agreement in space characterized by 26.

In the dynamical model considered, the adaptive and interacting swarming agents are modeled as self-propelled particles for which the biological details of the internal origin of an agent's thrust is considered to be irrelevant. Such SPP-based models are a good representation of collective animal behaviors11. Here, these SPPs are moving about a two-dimensional plane with constant speed v0 and subject to a topological neighborhood of interaction (see Fig. 4.A for a schematic of metric versus topological neighborhood of interactions). As mentioned previously, each agent i is fully characterized by its direction of travel—in other words, here ψi(t) = θi(t)—related to the agent's velocity through . The local synchronization protocol, based on relative states, is strictly equivalent to a local linear alignment rule which mathematically can be stated as:

where is the set of outdegree neighbors in the topological neighborhood of interaction of agent i, with cardinal number and wij is the binary weight of the ij communication link. Note that in some models, wij can take a more complicated form than our binary choice38,49,50. Using the k-nearest neighbor rule to define the topological distance, we have (see Fig. 4 for the case k = 7) and the following dynamical equation for each individual agent i in the swarm:

where are its k-nearest neighbors' velocity directions. The dynamics of the agents in the two-dimensional physical space is intricately coupled to the dynamics of the signaling network which is the information transfer channel underlying the swarm dynamics. Constituent links of the swarm signaling network (SSN) of a group whose agents have directed interactions are unidirectional by opposition to bidirectional interactions in a group of agents with undirected interaction edges. The topological neighborhood of interaction based on the k-nearest neighbor rule allows one to locally identify the links between agents (see Fig. 4.B). The topological character of the neighborhood of interaction has a tremendous impact on the properties of interagent connectivity, in particular with induced asymmetry in the relationship whereby if agent j is in the neighborhood of agent i, then i is not necessarily in the neighborhood of j—the interaction is directed as well as the flow of information (see directed edges in Fig. 4.B). Note that with a metric neighborhood, the interagent connectivity is fundamentally symmetric hence leading to an undirected flow of information. The SSN, obtained by a straightforward bottom-up assembly process, is a switching k-nearest neighbor digraph, for which the specific value of k has a direct impact on its strongly connected character22. More precisely, Komareji & Bouffanais22 have shown that the SSN is a homogeneous clustered small-world network facilitating emergent outcomes if connectedness is maintained.

Figure 4
figure 4

(A) (Left) Schematics of metric (top) vs. topological (bottom) neighborhood of interactions. R is the radius of the metric neighborhood and r is the radius of the topological one based on the rule of k-nearest neighbors with k = 7. R is constant as it defines a metric zone around the agent while r changes in accordance with the distance between the agent and its k-th (here 7-th) nearest neighbor. (B) (Right) Snapshot of a swarm of N = 100 of agents whose directions are represented by black arrowheads. The N agents interact topologically with their k = 7 nearest neighbors and the associated signaling network is shown. Nodes and edges are colored according to the topological distance (increasing distance from blue to red).

Using a network-theoretic approach, the dynamical equations (10) for the swarm dynamics can be recast in the following global compact form

where and L(t) is the outdegree-based graph Laplacian of the SSN, which is a k-nearest neighbor digraph.

Noise can generally be assumed to be random fluctuations with a normal distribution51. In the sequel, whenever the effects of noise are accounted for, a background noise having a normal distribution—fully characterized by its noise level η—will be considered. Specifically, a random number Δθ chosen with a uniform probability from the interval [−η/2, η/2] will be added to the agent's direction of travel θi at each time step using a discrete-time approach.