-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile_directed_mp_rw.py
74 lines (57 loc) · 2.23 KB
/
profile_directed_mp_rw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# from igraph import *
import igraph as ig
import easygraph as eg
# from easygraph.functions.centrality.closeness import closeness_centrality_parallel
# from easygraph.functions.centrality.betweenness import betweenness_centrality_parallel
from benchmark import benchmark
import sys
import random
import os
import numpy as np
n = 5
def random_nodes(nodes_num, start_idx, end_idx, seed=0):
random.seed(seed)
node_list = []
for i in range(nodes_num):
node_list.append(random.randint(start_idx, end_idx))
return node_list
def pre_data(path, file):
# print(file)
data = np.loadtxt(path+file,usecols=(0,1))
np.savetxt(path+file, data, fmt='%i')
return path+file
if __name__ == "__main__":
print('for directed networks..............')
filepath = 'datasets/directed_datasets/'
filelist = os.listdir(filepath)
print(filelist)
for file in filelist:
print(f"Profiling dataset {file}")
print("Profiling loading")
print("=================")
print()
file = pre_data(filepath, file)
g = eg.DiGraph()
g.add_edges_from_file(file, weighted=False)
print('*****************************')
print(len(g.nodes), len(g.edges))
print("graph name:,", file)
worker_list = [4, 8, 16]
for n_workers in worker_list:
print("n_workers=", n_workers)
print("========clustering=======")
print("=================")
print()
benchmark('eg.clustering(g, n_workers=n_workers)', globals=globals(), n=n)
print("========hierarchy=======")
print("=================")
print()
benchmark('eg.hierarchy(g, n_workers=n_workers)', globals=globals(), n=n)
print("========closeness_centrality=======")
print("=================")
print()
benchmark('eg.closeness_centrality(g, n_workers=n_workers)', globals=globals(), n=n)
print("========betweenness_centrality=======")
print("=================")
print()
benchmark('eg.betweenness_centrality(g, n_workers=n_workers)', globals=globals(), n=n)