summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/main.c b/main.c
index ad07324..50a9f64 100644
--- a/main.c
+++ b/main.c
@@ -28,11 +28,49 @@ void max_clique_a(const graph g, set k, set c, set *mc) {
delete_set(k2);
delete_set(c2);
}
+ delete_set(cc);
}
}
-int main() {
- graph g = load_graph(stdin);
+
+// Driver
+
+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 -h, --help\n\tShow this help page\n");
+}
+
+int main(int argc, char **argv) {
+ int i;
+ int dimacs = 0;
+ char *filename = "-";
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-d")) {
+ dimacs = 1;
+ } else if (argv[i][0] == '-') {
+ usage(argv[0]);
+ return 0;
+ } else {
+ filename = argv[i];
+ }
+ }
+
+ FILE *f = stdin;
+ if (strcmp(filename, "-")) {
+ f = fopen(filename, "r");
+ if (f == NULL) {
+ fprintf(stderr, "Error: could not open file %s\n", filename);
+ return 1;
+ }
+ }
+ graph g = (dimacs ? load_graph_dimacs(f) : load_graph(f));
+ if (g == NULL) {
+ fprintf(stderr, "Error loading file %s\n", filename);
+ return 1;
+ }
dump_graphviz(g, stdout);
// do stuff with graph