def initializer(self):
        """ Initialize the host algorithm """

        for node in self.network.nodes():

            node.memory['neighbors_data'] = {}
            node.points = [(int(node.network.pos[node][0]),
                            int(node.network.pos[node][1]))]
            node.voronoi = Delaunay()
            VoronoiDiagram.new_diagram(node.voronoi, str(node.id))
            node.voronoi.include(node.points[0])

        super(DistributedVoronoi, self).initializer()
예제 #2
0
 def new_thread(points, delay, n, lines, columns, fps = 0, 
                  test_class = DiagramTest):
     # test multi-thread execution: 
     VoronoiDiagram.start(title = test_class.__name__ + 
                          " - New-thread test", 
                          lines = lines, columns = columns, fps_limit = fps)
     # configure
     threads = []
     # create tests in different threads
     for i in xrange(0,n):
         test = test_class(points, delay)
         threads.append(test)
         VoronoiDiagram.new_diagram(test.diagram, label="test")
         test.start()
     # waiting until previewer terminates
     while VoronoiDiagram.in_state(Preview.RUNNING):
         pass
     # stop tests threads
     for t in threads:
         t.stop()