No leader, no map, just neighbours
A swarm of drones flying in a tight V or a rotating circle looks choreographed from the outside, but nothing in the swarm has a copy of that choreography. Each drone runs the same simple rule using only what it can see or hear from its immediate neighbours — no central controller broadcasts positions, no drone has a global map of the formation. This is consensus: a family of distributed algorithms where local agreement between neighbours produces coordinated global behaviour, and it is how this site's swarm demo self-organizes into line, V, grid and circle formations.
The consensus update
The canonical linear consensus protocol has each agent i nudge its state x_i toward the average of its neighbours' states, weighted by how connected they are:
x_i(t+1) = x_i(t) + eps * sum_{j in N(i)} ( x_j(t) - x_i(t) )
For formation flying, x_i is not the drone's absolute position but its position relative to its assigned formation slot. Every drone knows its own offset within the target shape (drone #3's slot is 2 m behind and 1 m left of the flock centroid, say) and applies the consensus rule to a modified error term — the difference between its actual relative position and its desired relative position, averaged against what its neighbours report about theirs. Drive that error to zero everywhere and the whole flock has locked into formation, even though no drone ever computed the shape as a whole.
Why the communication graph matters more than the rule
The update above only works if information can actually reach every drone, possibly through several hops. Represent the swarm as a graph — a node per drone, an edge whenever two drones are within communication or sensing range — and the relevant object is the graph Laplacian L = D - A (degree matrix minus adjacency matrix). Consensus theory proves convergence happens if and only if the graph is connected: there is some path, direct or relayed, between every pair of drones. The algebraic connectivity — the second-smallest eigenvalue of L, often called lambda-2 or the Fiedler value — controls how fast: a larger lambda-2 means faster convergence, a graph on the edge of becoming disconnected has lambda-2 near zero and consensus crawls.
L = D - A D = diag(degree of each node) A = adjacency matrix (1 if i, j can communicate, else 0) lambda_2(L) > 0 iff graph is connected iff consensus converges lambda_2(L) large => fast convergence; lambda_2(L) -> 0 => convergence stalls
This is why a real swarm's formation controller is inseparable from its network topology problem: if drones spread out until the communication graph fractures into two disconnected clusters, each cluster reaches its own local consensus and the swarm splits into two formations that never agree with each other. Maintaining connectivity — sometimes explicitly, by biasing motion to avoid isolating a peripheral drone — is as much a part of formation control as the consensus law itself.
From consensus to shapes: line, V, grid, circle
Switching formations is just switching the target offset table every drone holds — the consensus law itself never changes. A V-formation assigns each drone a slot along two diverging rays behind a virtual leader point (echoing the aerodynamic drafting formation geese use); a grid assigns a rectangular lattice of offsets; a circle assigns offsets at equal angles around a centroid at a fixed radius. Because the underlying protocol is shape-agnostic, the demo can hot-swap formations and watch the swarm re-converge, driven by nothing more than each drone re-reading its new slot and re-running the same neighbour-averaging rule.
Real multi-UAV systems add two practical layers on top: a collision-avoidance term (a short-range repulsive force, similar to the potential fields used in single-drone path planning) so consensus never commands two drones to occupy the same slot transiently, and a leader-follower variant where one or a few agents track an external reference trajectory while the rest apply ordinary consensus to a virtual offset from the leader — useful when the whole formation needs to move somewhere specific rather than just self-organize in place.
Frequently asked questions
Does any drone in the swarm know the full formation shape?
No. Each drone only knows its own target offset within the formation and the states reported by its immediate neighbours. The formation shape emerges from every drone locally minimizing its own error against those neighbours — there is no drone, and no external controller, holding a global picture.
What happens if the communication graph becomes disconnected?
Consensus only converges to a single agreed formation if the graph stays connected — some path, even multi-hop, must exist between every pair of drones. If the swarm spreads out enough that the graph splits into separate clusters, each cluster converges to its own local consensus independently, and the swarm effectively fractures into multiple formations.
How fast does the swarm converge to a new formation?
Convergence speed is governed by the algebraic connectivity of the communication graph — the second-smallest eigenvalue of the graph Laplacian, lambda-2. A densely connected swarm converges quickly; a sparsely connected one, especially one close to fracturing into disconnected clusters, converges slowly because information takes longer to propagate across the whole group.
Try it live
Everything above runs in your browser — open Drone Formation Flying and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Drone Formation Flying simulation