Skip to content
Snippets Groups Projects
Commit 1e6579e7 authored by Radek Hušek's avatar Radek Hušek
Browse files

improve count_cdc

Do not slurp whole input at the beginning and keep
extra data in json.
parent d12c97fb
Branches
No related tags found
No related merge requests found
......@@ -7,19 +7,22 @@ from graph_tools.misc import count_cdc_naive
from sage.all import Graph
from parmap import parmap
def process(g6):
g6 = g6.rstrip()
G = Graph(g6)
def process(l):
j = json.loads(l)
G = Graph(j["graph"])
ret = count_cdc_naive(G)
return json.dumps({
"graph": g6,
j.update({
"cdc_count": ret[0],
"n": G.num_verts(),
"expected_cdc_lowerbound": ret[1],
"is_ok": (ret[0] >= ret[1])
})
inp = [ l for l in sys.stdin ]
return json.dumps(j)
inp = os.fdopen(sys.stdin.fileno())
sys.stdin = None
nprocs = int(os.getenv("NPROCS", "0")) or None
for ret in parmap(process, inp, nprocs=nprocs, in_order=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment