-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.py
More file actions
81 lines (63 loc) · 2.09 KB
/
checker.py
File metadata and controls
81 lines (63 loc) · 2.09 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
74
75
76
77
78
79
80
81
from dimacs import *
import os
from time import time
def sat_checker(f):
passed = failed = 0
dir = os.listdir("graphs-lab7/sat")
i = 0
a = time()
for graph in dir:
print(graph)
V, E = loadCNFFormula("graphs-lab7/sat/" + graph)
sol = bool(int(readSolution("graphs-lab7/sat/" + graph)[-1]))
res = f(E)
if res == sol:
print("Test " + str(i) + ": Passed")
passed += 1
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(res) + ", should be: " + str(sol))
failed += 1
i += 1
print("Time: " + str(time() - a) + " s")
print("Passed: " + str(passed))
print("Failed: " + str(failed))
def planarity_checker(f):
passed = failed = 0
dir = os.listdir("graphs-lab7/planarity")
i = 0
a = time()
for graph in dir:
print(graph)
V, E = loadWeightedGraph("graphs-lab7/planarity/" + graph)
sol = bool(int(readSolution("graphs-lab7/planarity/" + graph)))
res = f(E)
if res == sol:
print("Test " + str(i) + ": Passed")
passed += 1
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(res) + ", should be: " + str(sol))
failed += 1
i += 1
print("Time: " + str(time() - a) + " s")
print("Passed: " + str(passed))
print("Failed: " + str(failed))
def maxflow_checker(f):
passed = failed = 0
dir = os.listdir("graphs-lab7/flow")
i = 0
a = time()
for graph in dir:
print(graph)
V, E = loadDirectedWeightedGraph("graphs-lab7/flow/" + graph)
sol = int(readSolution("graphs-lab7/flow/" + graph))
res = f(V, E)
if res == sol:
print("Test " + str(i) + ": Passed")
passed += 1
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(res) + ", should be: " + str(sol))
failed += 1
i += 1
print("Time: " + str(time() - a) + " s")
print("Passed: " + str(passed))
print("Failed: " + str(failed))