-
Notifications
You must be signed in to change notification settings - Fork 86
/
script_1_preprocess.py
125 lines (98 loc) · 4.18 KB
/
script_1_preprocess.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
import numpy as np
import torch
from code.DatasetLoader import DatasetLoader
from code.MethodWLNodeColoring import MethodWLNodeColoring
from code.MethodGraphBatching import MethodGraphBatching
from code.MethodHopDistance import MethodHopDistance
from code.ResultSaving import ResultSaving
from code.Settings import Settings
#---- 'cora' , 'citeseer', 'pubmed' ----
dataset_name = 'cora'
np.random.seed(1)
torch.manual_seed(1)
#---- cora-small is for debuging only ----
if dataset_name == 'cora-small':
nclass = 7
nfeature = 1433
ngraph = 10
elif dataset_name == 'cora':
nclass = 7
nfeature = 1433
ngraph = 2708
elif dataset_name == 'citeseer':
nclass = 6
nfeature = 3703
ngraph = 3312
elif dataset_name == 'pubmed':
nclass = 3
nfeature = 500
ngraph = 19717
#---- Step 1: WL based graph coloring ----
if 1:
print('************ Start ************')
print('WL, dataset: ' + dataset_name)
# ---- objection initialization setction ---------------
data_obj = DatasetLoader()
data_obj.dataset_source_folder_path = './data/' + dataset_name + '/'
data_obj.dataset_name = dataset_name
method_obj = MethodWLNodeColoring()
result_obj = ResultSaving()
result_obj.result_destination_folder_path = './result/WL/'
result_obj.result_destination_file_name = dataset_name
setting_obj = Settings()
evaluate_obj = None
# ------------------------------------------------------
# ---- running section ---------------------------------
setting_obj.prepare(data_obj, method_obj, result_obj, evaluate_obj)
setting_obj.load_run_save_evaluate()
# ------------------------------------------------------
print('************ Finish ************')
#------------------------------------
#---- Step 2: intimacy calculation and subgraph batching ----
if 1:
for k in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:#, 10, 15, 20, 25, 30, 35, 40, 45, 50]:
print('************ Start ************')
print('Subgraph Batching, dataset: ' + dataset_name + ', k: ' + str(k))
# ---- objection initialization setction ---------------
data_obj = DatasetLoader()
data_obj.dataset_source_folder_path = './data/' + dataset_name + '/'
data_obj.dataset_name = dataset_name
data_obj.compute_s = True
method_obj = MethodGraphBatching()
method_obj.k = k
result_obj = ResultSaving()
result_obj.result_destination_folder_path = './result/Batch/'
result_obj.result_destination_file_name = dataset_name + '_' + str(k)
setting_obj = Settings()
evaluate_obj = None
# ------------------------------------------------------
# ---- running section ---------------------------------
setting_obj.prepare(data_obj, method_obj, result_obj, evaluate_obj)
setting_obj.load_run_save_evaluate()
# ------------------------------------------------------
print('************ Finish ************')
#------------------------------------
#---- Step 3: Shortest path: hop distance among nodes ----
if 1:
for k in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
print('************ Start ************')
print('HopDistance, dataset: ' + dataset_name + ', k: ' + str(k))
# ---- objection initialization setction ---------------
data_obj = DatasetLoader()
data_obj.dataset_source_folder_path = './data/' + dataset_name + '/'
data_obj.dataset_name = dataset_name
method_obj = MethodHopDistance()
method_obj.k = k
method_obj.dataset_name = dataset_name
result_obj = ResultSaving()
result_obj.result_destination_folder_path = './result/Hop/'
result_obj.result_destination_file_name = 'hop_' + dataset_name + '_' + str(k)
setting_obj = Settings()
evaluate_obj = None
# ------------------------------------------------------
# ---- running section ---------------------------------
setting_obj.prepare(data_obj, method_obj, result_obj, evaluate_obj)
setting_obj.load_run_save_evaluate()
# ------------------------------------------------------
print('************ Finish ************')
#------------------------------------