Ejemplo n.º 1
0
def testUpdateReputation(G):
    rep = [[65333,40500,73500,15500,31833,45750],
           [62014,45998,63865,19646,38951,44181],
           [59532,48790,58188,22916,43239,43971]]
    result = True
    for i in range(0, 3, 1):
        G = graphrep.updateReputation(G)
        reputs = nx.get_node_attributes(G, 'reput')
        for j in range(0, len(reputs),1):
            repu = (int)(reputs[j]*100000)
            print(repu)
            result = result and (rep[i][j] == repu or rep[i][j] == repu+1)
    if(result):
        print("Test updateReputation succeeds")
    else:
        print("Test updateReputation fails")
Ejemplo n.º 2
0
def evolution(nbNodes, nbRepUpdates):
    G = graphgen.generator(nbNodes)
    layout = nx.spring_layout(G)
    G0 = G.copy()
    again = "y"
    n = 2
    while(again == "y" and n < 9):
        Gn = G.copy()
        for i in range(nbRepUpdates):
            for j in range(5):
                G = graphevo.delete_links(G)
                for k in range(10):
                    G = graphevo.create_links(G)
            G = graphrep.updateReputation(G)
        n += 1
        graphlib.plot_graphs([G0, Gn, G], layout)
        again = raw_input("Do you want to continue ? (y or n)")