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

improve test_exp_cdc.sh experiment

parent f12d7de1
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Test conjecture that every bridgeless cubic graph has
# at least 2^{n/2 - 1} circuit double covers on all
# graphs on $1 vertices. We know that minimal
# counterexample does not have 3 or 4-cycle so we skip
# those.
SIZES="4 6 8 10 12 14 16 18 20"
DOC="
Test conjecture that every bridgeless cubic graph has
at least 2^{n/2 - 1} circuit double covers on all
graphs of given size. We know that minimal
counterexample does not have 3 or 4-cycle so we skip
those.
The arguments should be the sizes of the graphs
to be tested. If it is empty it defaults to
$SIZES.
It requires geng from Nauty packaget to be in the PATH.
WARNING: This experiment takes a long time to complete.
"
echo "$DOC"
export PYTHONUNBUFFERED=x
geng -Ctfd3D3 $1 |
nice sage -python3 ../count_cdc.py > ${0%.sh}_$1.log
if [[ -n "$*" ]]; then
SIZES="$*"
fi
: ${LOG:=${0%.sh}-$SIZES.log}
: ${GENG:=geng}
SELF="$(readlink -f "$0")"
for s in $SIZES; do
"$GENG" -Ctfd3D3 $s
done |
nice python /dev/fd/5 "$(dirname "$SELF")" "$LOG" 5<<'EOF'
if True:
import sys, os
sys.path.append(sys.argv[1] + "/..")
import json
from graph_tools.misc import count_cdc_naive
from sage.all import Graph
from parmap import parmap
def process(l):
G = Graph(l)
ret = count_cdc_naive(G)
j = {
"cdc_count": ret[0],
"n": G.num_verts(),
"expected_cdc_lowerbound": ret[1],
"is_ok": (ret[0] >= ret[1])
}
return json.dumps(j), j["is_ok"]
inp = os.fdopen(sys.stdin.fileno())
sys.stdin = None
nprocs = int(os.getenv("NPROCS", "0")) or None
with open(sys.argv[2], "w") as log:
sys.stdout.write(" Processed 0 (failed 0)")
failed = 0
for i, (l, is_ok) in enumerate(parmap(process, inp, nprocs=nprocs, in_order=False)):
log.write(l + "\n")
failed += not is_ok
sys.stdout.write("\033[1K\r Processed %i (failed %i)" % (i+1, failed))
sys.stdout.flush()
print("\nDone")
EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment