Пример #1
0
 def find_MWOE(self):
     """This function finds the MWOE of all the edges."""
     if self.level == 0 or (len(self.mst_edges) -1) == 0 and \
             self.parent_edge is None) or len(self.mst_edges) == 0:
         edge = self.get_min_edge()
         ret_msg = Message()
         ret_msg = ret_msg.send_MWOE(edge.get_weight(), edge.id, self.process_id)
         return ret_msg
Пример #2
0
 def get_non_mst_edges(self):
     """This function is used to find the non mst edges."""
     self.non_mst_edges = []
     msg = Message()
     msg = msg.test_message(self.component_id)
     self.broadcast_messages(msg)
     rcvd_msgs = 0
     while rcvd_msgs != len(self.edges):
Пример #3
0
 def get_MWOE(self):
     msg = Message()
     msg = msg.get_MWOE()
     for edge in self.mst_edges:
         if edge == self.parent_edge
             continue
         edge.send_message(self.process_id, msg)
     recieved_mwoe_msgs = []
     while len(recieved_mwoe_edges) != len(self.mst_edges) - 1:
         for edge in self.mst_edges:
             status, msg = edge.receive_message(self.process_id)
             if not status:
                 continue
             recieved_mwoe_msgs.append(msg)
         time.sleep(0.5)
     min_edge_id = None
     min_weight = 1000000
     min_process_id = None
     for msg in recieved_mwoe_msgs:
         if msg.msg < min_weight:
             min_weight = msg.msg
             min_edge_id = msg.edge_id
             min_process_id = msg.process_id
     for edge in self.non_mst_edges:
         if edge.get_weight() < min_weight:
             min_weight = edge.get_weight()
             min_edge_id = edge_id
             min_process_id = self.process_id
     ret_msg = Message()
     ret_msg = ret_msg.send_MWOE(min_weight, min_edge_id, self.process_id)
     return ret_msg