diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-10 10:26:12 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-10 10:26:12 +0100 |
commit | 3a1b146a5761db20d243ae5224a962eeca19b506 (patch) | |
tree | 630d0ee85f4116e6b78c4814f2e92df85b5927b7 /main.c | |
parent | 919e3698123e07afdeedef82df645cd7bb02d32e (diff) | |
download | AlgoProg-Projet-3a1b146a5761db20d243ae5224a962eeca19b506.tar.gz AlgoProg-Projet-3a1b146a5761db20d243ae5224a962eeca19b506.zip |
Code reorganization
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -19,10 +19,11 @@ void usage(char *pname) { printf("\nUsage:\n\t%s [options] [<graph file>]\n\n", pname); printf("Available options:\n"); - printf("\n -d\n\tRead input in DIMACS format\n"); + printf("\n -x\n\tRead input in custom format instead of DIMACS format\n"); printf("\n -a\n\tUse algorithm A\n"); printf("\n -b\n\tUse algorithm B\n"); printf("\n -c\n\tUse algorithm C\n"); + printf("\n -cc\n\tUse algorithm C with coloring\n"); printf("\n -o <file.dot>\n\tDump graph in graphwiz .dot format\n"); printf("\n -h, --help\n\tShow this help page\n"); exit(1); @@ -30,14 +31,14 @@ void usage(char *pname) { int main(int argc, char **argv) { int i; - int dimacs = 0; + int dimacs = 1; char *filename = "-"; char *dump = NULL; int algo = 0; for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-d")) { - dimacs = 1; + if (!strcmp(argv[i], "-x")) { + dimacs = 0; } else if (!strcmp(argv[i], "-o")) { if (++i == argc) usage(argv[0]); dump = argv[i]; @@ -47,6 +48,8 @@ int main(int argc, char **argv) { algo = 1; } else if (!strcmp(argv[i], "-c")) { algo = 2; + } else if (!strcmp(argv[i], "-cc")) { + algo = 3; } else if (argv[i][0] == '-') { usage(argv[0]); } else { @@ -80,32 +83,33 @@ int main(int argc, char **argv) { } // do stuff with graph + set max_clique = empty_set(g->N); if (algo == 0) { - set max_clique = empty_set(g->N); set init_s = full_set(g->N); set init_k = empty_set(g->N); max_clique_a(g, init_k, init_s, &max_clique); - printf("Max clique: "); dump_set(max_clique); } else if (algo == 1) { - set max_clique = empty_set(g->N); set init_c = full_set(g->N); set init_a = full_set(g->N); set init_k = empty_set(g->N); max_clique_b(g, init_k, init_c, init_a, &max_clique); - printf("Max clique: "); dump_set(max_clique); } else if (algo == 2) { + set init_c = full_set(g->N); + set init_a = full_set(g->N); + set init_k = empty_set(g->N); + max_clique_c(g, init_k, init_c, init_a, &max_clique); + } else if (algo == 3) { set k = full_set(g->N); int clique_upper_bound = color_subgraph(g, k, 0); delete_set(k); printf("Upper bound on max clique size: %d\n", clique_upper_bound); - set max_clique = empty_set(g->N); set init_c = full_set(g->N); set init_a = full_set(g->N); set init_k = empty_set(g->N); - max_clique_c(g, init_k, init_c, init_a, &max_clique, g->N); - printf("Max clique: "); dump_set(max_clique); + max_clique_c_color(g, init_k, init_c, init_a, &max_clique, g->N); } + printf("Max clique: "); dump_set(max_clique); return 0; } |