#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include <stdbool.h>
#include <inttypes.h>
#include <publib.h>
typedef uint32_t AdjWord;
#define PRADJ "08"PRIx32
-static int n, m;
+static int n, m, maxhamweight;
static AdjWord *adjmatrix;
static AdjWord adjall;
retry_with_print:
#define PRINTF if (!doprint) ; else printf /* bodgy */
+ PRINTF("%2d ", maxhamweight);
+
+ bool had_max = 0;
for (i=0, totalfrags=0; i<n; i++) {
int frags = count_set_adj_bits(adjmatrix[i]);
+ had_max += (frags == maxhamweight);
totalfrags += frags;
PRINTF("%"PRADJ" ", adjmatrix[i]);
double maxminsize = (double)m / frags;
goto out;
}
}
+ if (!had_max) {
+ PRINTF(" nomaxham");
+ goto out;
+ }
/*
* We formulate our problem as an LP problem as follows.
for (adjmatrix[i] = min;
;
adjmatrix[i]++) {
+ if (count_set_adj_bits(adjmatrix[i]) > maxhamweight)
+ goto again;
+
iterate_recurse(i+1, adjmatrix[i]);
+
+ again:
if (adjmatrix[i] == adjall)
return;
}
}
static void iterate(void) {
- iterate_recurse(0, 1);
+ for (maxhamweight=1; maxhamweight<=m; maxhamweight++) {
+ double maxminsize = (double)m / maxhamweight;
+ if (maxminsize <= best)
+ continue;
+
+ iterate_recurse(0, 1);
+ }
}
int main(int argc, char **argv) {