-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.py
More file actions
64 lines (53 loc) · 1.95 KB
/
checker.py
File metadata and controls
64 lines (53 loc) · 1.95 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
from dimacs import *
import os
from time import time
def check1(f):
dir = os.listdir("graphs-lab2/flow")
for i in range(len(dir)):
if dir[i] == "grid100x100":
dir[i], dir[-1] = dir[-1], dir[i]
elif dir[i] == "clique200":
dir[i], dir[-2] = dir[-2], dir[i]
i = 0
a = time()
for graph in dir:
n, E = loadDirectedWeightedGraph("graphs-lab2/flow/" + graph)
result = f(E)
sol = int(readSolution("graphs-lab2/flow/" + graph))
if result == sol:
print("Test " + str(i) + ": Passed")
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(result) + ", should be: " + str(sol))
i += 1
print("Time: " + str(time() - a) + " s")
def check2(f, name = ''):
dir = os.listdir("graphs-lab2/connectivity")
for i in range(len(dir)):
if dir[i] == "grid100x100":
dir[i], dir[-1] = dir[-1], dir[i]
elif dir[i] == "clique200":
dir[i], dir[-2] = dir[-2], dir[i]
i = 0
a = time()
if len(name) > 0:
n, E = loadWeightedGraph("graphs-lab2/connectivity/" + name)
result = f(E)
sol = int(readSolution("graphs-lab2/connectivity/" + name))
if result == sol:
print("Test " + str(i) + ": Passed")
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(result) + ", should be: " + str(sol))
i += 1
print("Time: " + str(time() - a) + " s")
return
for graph in dir:
print(graph)
n, E = loadWeightedGraph("graphs-lab2/connectivity/" + graph)
result = f(E)
sol = int(readSolution("graphs-lab2/connectivity/" + graph))
if result == sol:
print("Test " + str(i) + ": Passed")
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(result) + ", should be: " + str(sol))
i += 1
print("Time: " + str(time() - a) + " s")