As the world watches with intense interest the quadrennial spectacle of the US presidential election and the endless sparring and debating, we discuss the most efficient way to elect a leader!

Television viewers are getting ready for another *Trumpillary* debate. The media has been licking its lips at skyrocketing TRP ratings supported by all the sparring and salacious stories. Since I’ve now got you here like those media channels, possibly against your will, let me tell you that this post is about electing a leader in a distributed network and is in, all likelihood, going to be much more boring than the US presidential election. This is not surprising at all, since the candidates in the distributed network are all honest, non-malicious, rational, ‘think’ in exactly the same manner, and really and truly interested in electing the best candidate!

Moreover, their desirability/’fitness’ is immediately comparable (e.g. given by a unique ID such as a mac address). Unfortunately, for the Trump(H)illary contest this would be like looking at the following picture and assiming the **hand mudras** define the candidates telling who will win e.g. will Trump’s *Gyan mudra* (i.e. *knowledge *hand gesture, which looks like F in the one hand sign language) trump Hillary’s *Abhay mudra? *(i.e. *Fearlessness hand gesture*, hmm, I hope you already see the contradictions!).

- Clinton and Trump try to win using hand mudras? (from https://goo.gl/gRMsQt)

OK, now to the technical part of this post. **Leader Election **is one of the most fundamental problems in distributed systems. The idea is simply to select one of the nodes in the network as a leader and let it solve the critical problem of the day and then just convey the solution to the rest of the network. Electing a leader can often be the first step in many systems and was formally introduced as a rigorous problem in the context of token ring networks by Le Lann (1977).

We were fortunate to derive some very interesting results for this classic problem in the past few years. This is in the form of the following two papers –

The first paper has some very interesting lower bounds (which were assumed to be folklore but never proven). One aim of the paper was to achieve algorithms which can meet the lower bounds- that is leader election algorithms for arbitrary topologies must need O(diameter) time and O(#edges) messages simulteneously. Algorithms which meet either O(diameter) time or O(#edges) messages ignoring the other parameter have been long known but achieving both simultaneously has been very challenging. The paper has randomised algorithms which (almost) achieve that. The paper also has what we consider the **best determinisitic leader election algorithm** in terms of achieiving both parameters simultaneously. The result is an **O(D.logn) time** and** O(m.logn) messages** algorithm called **The Double-Win Growing Kingdom Algorithm **(Here, D: diameter, n: #nodes, m:#edges). Yes, it is more bloody than *Game of Thrones! (Imdb rating; 9/5/10, wow).*

I tell the high level idea and show some (almost) cool animations by one of my students. Our algorithm turned out to be similiar to Abu-Amara and Kanevsky’s (ICCI 1993) algorithm which they erroneously thought to work in O(D) time and O(m + log n) messages. Here is an informal outline of the algorithm:

(Note that the network here is depicted as a graph with the computers/agents as nodes and interconnections between them as edges. The agents can only communicate by sending messages to their neighbours along these edges. So, we are designing a graph theoretical algorithm.)

Initially every node (each with a unique ID) in the network wants to be a leader i.e. is a candidate and begins with *radius=1*. Ultimately, the node with the highest ID will win. Each node tries to win over other nodes and expand their kingdom by conquering other nodes! The algorithm terminates when the sole candidate left cannot grow its kingdom anymore.

*In each round, for each node:*

*If candidate, double your radius of conquest and broadcast conquest messages over this radius (i.e. ask neighbours to forward the message)*
*If you get a message from a higher ranked node than you, drop out and join that node’s kingdom!*
*Collision: You get hit by messages from multiple candidates. Choose the highest rank one and join its kingdom. Do not further the winner messages!*
*Inform the winners of their boundary of conquest by sending back acknowledegments of victory along the path the conquest messages came (actually, a broadcast tree)*

… and so on…

The above idea is fairly straightforward but the main challenge is to keep the messages and time low – I am skipping the technical details except mentioning that each round in itself has four phases. This shows up in the following cool simulations done by my student Christopher (Thanks Christopher!):

LE Simulation: Grid

LE Simulation: QUB

LE Simulation: CrossLines

LE Simulation: Xmas Tree

Questions:

The ideal algorithm will be *O(D) time + O(m)* messages – there is a substantial gap here:

- Can a determistic algorithm achieve these bounds or get closer to it than the
*Double-Win Growing Kingdom* algorithm?
- Is there a better lower bound than
*O(D) time + O(m)* messages? i.e. Is the problem even more difficult than we think?

### Like this:

Like Loading...