def computeS(self,pos): list_m = self.graph.node[pos]['vector'] x = self.graph.node[self.graph.nodes()[pos]]['initVal'] list_sum = vector.initZeros(len(self.graph.nodes())) for i in range(0,len(list_m)): list_a = list_m[i] list_a = vector.mul(list_a.getV(),x) list_sum = vector.sum(list_sum,list_a.getV()) #compute alpha share to send list_sum = vector.mul(list_sum,self.alpha) return list_sum
def sendMessage(self,r): #start the algorithm vr = self.Net.getVr(self.pos,r-1) #calculate vti as sum(vr) in round t-1 vr = vector.mul(vr,self.alpha) m = msg.Message(r,v=vr) # create a new message to send it with vti * alpha-share self.Net.sendMessage(m) # send to all