-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (26 loc) · 914 Bytes
/
main.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
# TODO: copy the jupyter notebook codes to here, make it reproducable
import os
import fire
import lib.erdos as erdos
from lib.util import binom
def main(n, a, b, N, filename=None, signotope=False):
if signotope:
print("Signotope on")
inst = erdos.etv_signotope(n, a, b, N)
else:
inst = erdos.etv(n, a, b, N)
if not filename:
filename = f"etv_{n}_{a}_{b}_{N}"
if inst.solve(filename):
print("Solution found")
sol_filename = filename + ".color"
with open(sol_filename, "w") as f:
for triple, var in inst.v.items():
color = 'R' if var.solution() else 'B'
line = f"{triple[0]+1} {triple[1]+1} {triple[2]+1} {color}"
f.write(line + "\n")
print("Solution stored in " + sol_filename)
else:
print("Solution not found")
if __name__ == '__main__':
fire.Fire(main)