-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.py
More file actions
executable file
·81 lines (50 loc) · 1.41 KB
/
process.py
File metadata and controls
executable file
·81 lines (50 loc) · 1.41 KB
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
import sys
import random
Edge_DICT = {}
EDGE_SET =set([])
if __name__ == '__main__':
if len(sys.argv) != 3:
sys.exit('usage: process.py <input_graph_file> <input_gt_file>')
random.seed(17)
input_graph_file = sys.argv[1]
input_gt_file = sys.argv[2]
fOut = open('output_A_torus.txt', 'w')
fOut.write('insert into A_torus Values\n')
fIn = open(input_graph_file, 'r')
lines = fIn.readlines()
for line in lines:
parts = line.strip('\r\n').split('\t')
src = parts[0]
dst = parts[1]
wei = int(parts[2])
EDGE_SET.add((src, dst))
EDGE_SET.add((dst, src))
fIn.close()
# print (Edge_DICT)
counter = 0
for src,dst in EDGE_SET:
if counter == len( EDGE_SET ) - 1:
new_line = '\t(' + src + ',' + dst + ',' + '1);\n'#+ str(Edge_DICT[(src, dst)])
else:
new_line = '\t(' + src + ',' + dst + ',' + '1),\n'#+ str(Edge_DICT[(src, dst)])
counter += 1
fOut.write(new_line)
fOut.close()
candidates = []
fOut = open('output_E_torus.txt', 'w')
fOut.write('insert into E_torus Values\n')
fIn = open(input_gt_file, 'r')
counter = 0
lines = fIn.readlines()
for line in lines:
parts = line.strip('\r\n').split('\t')
init_class = int(parts[1])
for i in range(1,4,1):
print(i)
if i == init_class:
new_line = '\t(' + parts[0] + ',' + str(i) + ',2),\n'
else:
new_line = '\t(' + parts[0] + ',' + str(i) + ',-1),\n'
fOut.write(new_line)
fIn.close()
fOut.close()