简体   繁体   English

定向超立方体的领导者选举算法

[英]A leader election algorithm for an oriented hypercube

I'm stuck with some problem where I have to design a leader election algorithm for an oriented hypercube. 我遇到了必须为定向超立方体设计领导者选举算法的问题。 This should be done by using a tournament with a number of rounds equal to the dimension D of the hypercube. 这应该通过使用具有等于超立方体尺寸D的回合数的锦标赛来完成。 In each stage d, with 1 <= d < D two candidate leaders of neighbouring d-dimensional hypercubes should compete to become the single candidate leader of the (d+1)-dimensional hypercube that is the union of their respective hypercubes. 在每个阶段d中,在1 <= d <D的情况下,相邻d维超立方体的两个候选领导者应竞争成为(d + 1)维超立方体的单个候选领导者,这是它们各自超立方体的并集。

It has been a long time since I studied distributed systems, but I hope this helps a little :) 自研究分布式系统以来已经有很长时间了,但是我希望这可以有所帮助:)

The problem: Leader election in a network with a hypercube tolopogy. 问题是: 超立方体拓扑网络中的领导者选举 In this topology, every node has exactly D neighbors (where D is the hypercube's dimension). 在此拓扑中,每个节点都具有完全D个邻居(其中D是超立方体的维)。 Since the hypercube is oriented , the nodes know which of their links corresponds to every dimension. 由于超立方体是定向的 ,因此节点知道其哪个链接对应于每个维度。 Also, I assume that all nodes are labeled with some unique id, as typical with this kind of problems. 另外,我假设所有节点都带有一些唯一的ID,这是此类问题的典型表现。

If I understand well your solution guidelines, the algorithm seems to be simple: a node has exactly D states. 如果我很了解您的解决方案准则,该算法似乎很简单:一个节点的状态完全为D。 In every state 1<=d<=D it communicates with its neighbor along the d axis. 在每个状态1 <= d <= D中,它都沿d轴与其邻居通信。 This communication consists of sending it the id of the best candidate it is aware of (when d=1 this is simply its own id), and comparing it with the id received by the peer. 这种通信包括向其发送它知道的最佳候选者的ID(当d = 1时,这只是其自身的ID),并将其与对等方接收的ID进行比较。 Now the node knows the best id of the sub-cube of order d (defined by axes 1,2...,d) it belongs to. 现在,该节点知道它所属的d阶子多维数据集(由轴1,2 ...,d定义)的最佳id。 This way, at step D all nodes are aware of the global best, and the algorithm completes with a consensus. 这样,在步骤D,所有节点都知道全局最佳,并且算法以共识的方式完成。

For example, assume the following topology(D=2) and id values: 例如,假定以下拓扑(D = 2)和id值:

   (1)    (2)
    1-----2
    |     |
    |     |
    4-----3
   (4)    (3)

The ids in parentheses indicate the best ids known by each node so far. 括号中的id表示到目前为止每个节点已知的最佳id。

The first iteration (d=1) works along the horizontal axis, and terminates as follows: 第一次迭代(d = 1)沿水平轴工作,并如下终止:

   (2)    (2)
    1-----2
    |     |
    |     |
    4-----3
   (4)    (4)

The second (and last) iteration (d=2) works along the vertical axis, and terminates as follows: 第二次(也是最后一次)迭代(d = 2)沿垂直轴工作,并终止如下:

   (4)    (4)
    1-----2
    |     |
    |     |
    4-----3
   (4)    (4)

The node number 4 has been chosen, as required (highest id). 已根据需要选择了节点号4(最高ID)。

Message count complexity 邮件计数复杂度

For every edge in the hypercube we have exactly 2 messages (one on each direction). 对于超立方体中的每个边缘,我们都有2条消息(每个方向一条)。 Since the formula for the number of edges in a hypercube of dimension D is E=D*2^(D-1), we have exactly M=D*2^D messages. 由于维D的超立方体中边数的公式为E = D * 2 ^(D-1),因此我们有M = D * 2 ^ D条消息。 In order to compute the complexity as a function of N (the number of nodes), recall that N = 2^D, so M=N*log N. 为了计算复杂度作为N(节点数)的函数,请回想N = 2 ^ D,所以M = N * logN。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM