-
Notifications
You must be signed in to change notification settings - Fork 1
/
bench_soc.py
executable file
·141 lines (119 loc) · 3.61 KB
/
bench_soc.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env python3
"""
Author : Xinyuan Chen <45612704+tddschn@users.noreply.github.com>
Date : 2022-08-03
Purpose: EasyGraph & NetworkX side-by-side benchmarking
"""
from hr_tddschn import hr
from config import (
eg_master_dir,
load_functions_name,
di_load_functions_name,
clustering_methods,
shortest_path_methods,
# connected_components_methods,
connected_components_methods_G,
connected_components_methods_G_node,
mst_methods,
method_groups,
dataset_names,
)
from utils import eg2nx, eg2ceg, get_first_node, eval_method
# if eg_master_dir.exists():
# import sys
# sys.path.insert(0, str(eg_master_dir))
import easygraph as eg
import networkx as nx
from dataset_loaders import load_bio, load_cheminformatics, load_eco, load_soc # type: ignore
load_func_name = 'load_soc'
G_eg = load_soc()
G_nx = eg2nx(G_eg)
G_ceg = eg2ceg(G_eg)
first_node_eg = get_first_node(G_eg)
first_node_nx = get_first_node(G_nx)
first_node_ceg = get_first_node(G_ceg)
import argparse
def get_args():
"""Get command-line arguments"""
parser = argparse.ArgumentParser(
description='EasyGraph & NetworkX side-by-side benchmarking',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
# parser.add_argument(
# '-d',
# '--dataset',
# type=str,
# choices=dataset_names,
# nargs='+',
# )
parser.add_argument(
'-G', '--method-group', type=str, choices=method_groups, nargs='+'
)
parser.add_argument(
'-C',
'--skip-cpp-easygraph',
'--skip-ceg',
action='store_true',
help='Skip benchmarking cpp_easygraph methods',
)
# parser.add_argument('-n', '--dry-run', action='store_true', help='Dry run')
return parser.parse_args()
args = get_args()
def main(args):
method_groups = args.method_group
flags = {}
flags |= {'skip_ceg': args.skip_cpp_easygraph}
cost_dict = {}
first_node_args = {
'call_method_args_eg': ['first_node_eg'],
'call_method_args_nx': ['first_node_nx'],
'call_method_args_ceg': ['first_node_ceg'],
}
if method_groups is None or 'clustering' in method_groups:
# bench: clustering
for method_name in clustering_methods:
eval_method(
cost_dict,
load_func_name,
method_name,
**flags,
)
if method_groups is None or 'shortest-path' in method_groups:
# bench: shortest path
# bench_shortest_path(cost_dict, g, load_func_name)
eval_method(
cost_dict,
load_func_name,
('Dijkstra', 'single_source_dijkstra_path'),
**first_node_args,
**flags,
)
if method_groups is None or 'connected-components' in method_groups:
# bench: connected components
for method_name in connected_components_methods_G:
eval_method(
cost_dict,
load_func_name,
method_name,
**flags,
)
for method_name in connected_components_methods_G_node:
eval_method(
cost_dict,
load_func_name,
method_name,
**first_node_args,
**flags,
)
if method_groups is None or 'mst' in method_groups:
# bench: mst
for method_name in mst_methods:
eval_method(
cost_dict,
load_func_name,
method_name,
**flags,
)
print()
if __name__ == "__main__":
main(args)