-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolver.py
30 lines (27 loc) · 963 Bytes
/
solver.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
import matplotlib.pyplot as plt
import sys
import subprocess
def get_color(x):
l = plt.rcParams['axes.prop_cycle'].by_key()['color']
return l[x % len(l)]
def main():
lines = subprocess.check_output(['./router.exe', sys.argv[1]]).decode('utf-8').split('\n')
n, m = map(int, lines[0].split(' '))
plt.figure('Result')
endpoints = False
for line in lines[1:]:
try:
if not endpoints:
x1, y1, x2, y2, net = map(int, line.split('-')[:5])
plt.plot([x1, x2], [y1, y2], color = get_color(net))
plt.scatter(x1, y1, color = get_color(net), s = 8)
plt.scatter(x2, y2, color = get_color(net), s = 8)
else:
x, y, net = map(int, line.split())
plt.scatter(x, y, color = get_color(net), s = 24)
except:
import traceback
endpoints = True
plt.show()
if __name__ == '__main__':
main()