Пример #1
0
# s=res_list_r[0:k]
# time_pagerank=time.time()-time_pagerank_start
# print time_pagerank
# S = map(int, s)

###k-核
time_kshell_start=time.time()
G_KShell=KShell_Centrality(G_init)

KShell_sort=sorted(G_KShell.iteritems(), key=lambda d:d[1], reverse = True)
res_list_k = [x for x,_ in KShell_sort]
s=res_list_k[0:k]
time_kshell=time.time()-time_kshell_start
print time_kshell
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 = runIC05(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')
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
    avg8 += float(len(T8)) / iterations
    avg9 += float(len(T9)) / iterations
    SUM_LENGTH1 += len(T1)
    SUM_LENGTH2 += len(T2)
Пример #3
0
 SUM_LENGTH9 = 0
 tt1 = []
 tt2 = []
 tt3 = []
 tt4 = []
 tt5 = []
 tt6 = []
 tt7 = []
 tt8 = []
 tt9 = []
 for i in range(iterations):
     T1 = runIC01(G, S)
     T2 = runIC02(G, S)
     T3 = runIC03(G, S)
     T4 = runIC04(G, S)
     T5 = runIC05(G, S)
     T6 = runIC06(G, S)
     T7 = runIC07(G, S)
     T8 = runIC08(G, S)
     T9 = runIC09(G, 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
     avg8 += float(len(T8)) / iterations
     avg9 += float(len(T9)) / iterations
     SUM_LENGTH1 += len(T1)
     SUM_LENGTH2 += len(T2)