def main():
    #Inicijaliziraj mrezu
    net_gen = NetworkGenerator(n_min=3, n_count=5, n_max=10)   # broj nodova
    net = net_gen.generate_random_network()

    #Add distance sensor
    for node in net.nodes():
        node.compositeSensor = (NeighborsSensor, DistSensor)

    #Postavi algoritam i INITIATOR node
    net.algorithms = ((PTConstruction, {'informationKey': 'I'}),)

    #Samo jedan node je INITIATOR!
    some_node = net.nodes()[0]
    some_node.memory['I'] = 'Hello distributed world'

    write_npickle(net, 'PTConstruction.tar.gz')

    #Napravi simulaciju 
    sim = Simulation(net)
    # sim.reset()

    #Debug
    print "Prije pokretanja!"

    #Pokreni
    sim.run()

    for node in net.nodes():
        print node.memory

    net.show(savefig="image.png")
def main():
    """ Definiranje main funkcije .... """

    #Inicijaliziraj mrezu
    net_gen = NetworkGenerator(100)   # implementirat broj nodova
    net = net_gen.generate_random_network()

    #Postavi algoritam i INITIATOR node
    net.algorithms = ((ShoutAlgorithm, {'informationKey': 'I'}),)


    # Zamjena range(1) za jedan node(Shout) ili vise(10) za multishout.
    # Definiranje random INIT nodova
    # for random_counter in range(1):

    for random_counter in range(1):
        rand_number = randrange(0, 100)
        some_node = net.nodes()[rand_number]
        some_node.memory['I'] = 'Slanje vremena'


    #Napravi simulaciju, spremi u datoteku "Shout.tar.gz"
    sim = Simulation(net)
    write_npickle(net, 'Shout.tar.gz')
    #sim.reset()

    #Pokreni
    sim.run()

    # print memorije nodova ... 
    for node in net.nodes():
        print node.memory

    #Spremanje dijagrama nodova kao slika u png formatu
    net.show(savefig="image.png")