计算路由表的分布式算法-Toueg算法(节点u)

1、在以w为枢纽节点的那一个轮的开始,满足Du[w]<∞(u到w的距离)的节点u知道它的父节点(Tw中)是谁,但不知道它的子节点。因此,每个节点V必须向它的每个近邻u发送消息,告知u是否v是u在Tw中的子节点。当一个节点得知它的近邻中哪些是它在Tw中的子节点时,就可以参加转发W表的过程

2、Neighu是指u的近邻节点。

3、

1)如果x是u的父节点(Tw中),则在w为枢轴节点的那一轮的开始,u将消息发送至x。

2)如果x不是u的父节点(Tw中),则在w为枢轴节点的那一轮的开始,u将消息发送至x。

3)在以w为中心的那一轮中,发送消息。经过Tw的每条边把Dw的值传输到需要该值的每一节点中。

4、

var Su:set of nodes;

      Du:array of weights;

      Nbu:array of nodes;

begin Su:=Φ;

     forall v∈V do

           if v=u

              then begin Du[v]:=0;Nbu[v]=udef end

              else if v Neighu

                         then begin Du[v]:=Wuv;Nbu[v]:=v end

                         else begin Du[v]:=∞;Nbu[v]:=udef end;

    while Su≠V do

             begin pick w from V\Su;

                  (*construct the tree Tw*)

                  forall x∈Neighu do

                          if Nbu[W]=x then send to x

                                             else  send to x;

                 num_recu:=0;(*必须要接收所有邻接节点的消息*)

                 while num_recu<|Neighu| do

                          begin receive or message;

                                    num_recu:=num_recu+1

                          end;

                 if Du[w]<∞ then

                        begin if u≠w

                                     then receive from this Nbu[w];

                                 forall x∈Neighu do

                                          if was received from x

                                              then send to x; 

                                forall  v∈V do

                                          if Du[w]+D[v]

                                             begin Du[w]:=Du[w]+D[v];

                                                       Nbu[v]:=Nbu[w]

                                              end

                     end;

                     Su:=Su∪{w}

            end

end

                           

        

你可能感兴趣的:(数学与计算)