コード例 #1
0
ファイル: simulation.py プロジェクト: pantuza/mestrado
# Defines the network algorithm
net.algorithms = ((DistributedVoronoi, {'informationKey':'axis'}),)


# Assign to node memory its position
for node in net.nodes():
    node.memory['axis'] = (int(net.pos[node][0]), int(net.pos[node][1]))


# Creates and starts the simulation
sim = Simulation(net)
sim.run()

# Show the State of the Voronoi Algorith execution
#print net.algorithmState


# Plot voronoi diagram for each node
for node in net.nodes():
    
    try:
        while VoronoiDiagram.preview.step(): pass
    except AttributeError:
        print "%s Insufficient number of nodes to compute voronoi" % node


VoronoiDiagram.stop()
# Writes
#write_npickle(net, "net.gz")
sim.reset()