-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviz.py
executable file
·42 lines (33 loc) · 1.53 KB
/
viz.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
import csv
from subprocess import call
rows = []
with open("output.csv", "rb") as csvFile:
reader = csv.reader(csvFile)
for row in reader:
rows.append(row)
rows.sort(key=lambda x: x[2])
for row in rows:
print row
f = open("pic.dot", "w")
f.write("digraph {\n\nrankdir = TB\n\n")
#print rows[0][4] + ' ** ' + rows[0][5] + ' ** ' + rows[0][6]
f.write('0 [label="' + rows[0][2] + '\\n' + rows[0][4] + '" shape=box style="filled" fillcolor="#CCCCFF"]\n')
f.write('1 [label="' + rows[0][0] + '\\n' + rows[0][1] + '\\n' + rows[0][5] + '" shape=box style="filled" fillcolor="#FFFFCC"]\n')
f.write('2 [shape=point width = 0.2]\n')
f.write('3 [label="' + rows[0][2] + '\\n' + rows[0][6] + '" shape=box style="filled" fillcolor="#CCFFCC"]\n')
f.write('0 -> 2;\n')
f.write('1 -> 2 [style="dashed"];\n')
f.write('2 -> 3;\n')
index = 3
for i in range(1, len(rows)):
# print rows[i-1][6] + ' ** ' + rows[i][5] + ' ** ' + rows[0][6]
f.write(str(index+1) + ' [label="' + rows[i][0] + '\\n' + rows[i][1] + '\\n' + rows[i][5] + '" shape=box style="filled" fillcolor="#FFFFCC"]\n')
f.write(str(index+2) + ' [shape=point width = 0.2]\n')
f.write(str(index+3) + ' [label="' + rows[i][2] + '\\n' + rows[i][6] + '" shape=box style="filled" fillcolor="#CCFFCC"]\n')
f.write(str(index) + ' -> ' + str(index+2) + ';\n')
f.write(str(index+1) + ' -> ' + str(index+2) + ' [style="dashed"];\n')
f.write(str(index+2) + ' -> ' + str(index+3) + ';\n')
index = index + 3
f.write('}\n')
f.close()
call("rm output.csv", shell=True)