我有一个异步网络无向树(V,E),其中n = | V |流程。我对我的网络唯一了解的是,所有进程都有唯一的ID(UID),他们知道邻居的数量,但是他们不知道网络的直径和大小。我试图在这样的网络中构建领导者选举算法,如下所示:
A convergecast of <leader> messages is initiated starting from the
leaves of the tree.
Each leaf node is initially enabled to send a <leader> message to
its unique neighbor. Any node that receives <leader> messages from
all but one of its neighbors is enabled to send an <leader> message
to its remaining neighbor.
In the end,
1. Some particular process receives <leader> messages along all
of its channels before it has sent out an <leader> message
the process at which the <leader> messages converge elects
itself as the leader.
2. <leader> messages are sent on some particular edge in both
directions.
the process with the largest pid among the processes that are
adjacent to this edge elects itself as the leader.
我的想法正确吗,以上算法是否在知道领导者的所有过程中终止?
您的算法是正确的,但具有以下限制:
我不知道这些限制对您是否有问题。由于我的信誉不足,无法对您的问题发表评论,因此我也无法提出要求。
算法的正确性可以通过数学归纳证明。
归纳步骤:将节点添加到树中。有两种情况:
a)新节点连接到以前不是叶的节点。
b)新节点连接到先前为叶的节点。
在两种情况下都不难证明算法的输出正确。因此,该算法对于所有树木都是正确的。