SUM_LENGTH5 = 0
SUM_LENGTH6 = 0
SUM_LENGTH7 = 0
SUM_LENGTH8 = 0
SUM_LENGTH9 = 0
tt1 = []
tt2 = []
tt3 = []
tt4 = []
tt5 = []
tt6 = []
tt7 = []
tt8 = []
tt9 = []
for i in range(iterations):
    T1 = runIC01(G1, S)
    T2 = runIC02(G1, S)
    T3 = runIC03(G1, S)
    T4 = runIC04(G1, S)
    T5 = runIC05(G1, S)
    T6 = runIC06(G1, S)
    T7 = runIC07(G1, S)
    T8 = runIC08(G1, S)
    T9 = runIC09(G1, S)
    avg1 += float(len(T1)) / iterations
    avg2 += float(len(T2)) / iterations
    avg3 += float(len(T3)) / iterations
    avg4 += float(len(T4)) / iterations
    avg5 += float(len(T5)) / iterations
    avg6 += float(len(T6)) / iterations
    avg7 += float(len(T7)) / iterations
Esempio n. 2
0
    CI = Collective_Influence(G)
    CI_sort = sorted(CI.iteritems(), key=lambda d: d[1], reverse=True)
    id_CI_k = [x for x, _ in CI_sort]
    s_CI.append(id_CI_k[0])
    remove_node1(G, id_CI_k[0])
    c = c + 1
time_CI = time.time() - time_CI_start
print time_CI
print s_CI
S = s_CI
print s_CI
S = map(int, S)
S1 = []
with open(r'C:\Users\Administrator\Desktop\Political blogs_IC_ci.txt',
          'w') as gg:
    index = 0
    for i in S:
        index = index + 1
        S1.append(int(i))
        print S1
        iterations = 200  # number of iterations
        avg = 0
        SUM_LENGTH = 0
        for j in range(iterations):
            T = runIC01(G1, S1)
            avg += float(len(T)) / iterations
            SUM_LENGTH += len(T)
        #gg.write(str(index)+' '+str(int(round(avg)))+'\n')
        gg.write(str(int(round(avg))) + '\n')

# console = []