diff options
Diffstat (limited to 'src/main/online.c')
-rw-r--r-- | src/main/online.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/online.c b/src/main/online.c index fb400ef..fbec660 100644 --- a/src/main/online.c +++ b/src/main/online.c @@ -2,6 +2,7 @@ #include <time.h> #include <stdlib.h> #include <string.h> +#include <sys/time.h> #include "common.h" #include "structs.h" #include "dfs.h" @@ -22,7 +23,10 @@ int main(int argc, char * argv[]){ data = input(argv[5]); /* Sort data */ - srand(time(NULL)); + struct timeval tv; + gettimeofday(&tv, NULL); + srand(tv.tv_sec + tv.tv_usec); + if(strcmp(argv[3], "random") == 0) { qsort(data->items, data->N, sizeof(struct item), cmp_items_random); } else if(strcmp(argv[3], "ratio") == 0) { @@ -39,7 +43,7 @@ int main(int argc, char * argv[]){ } /* Run algorithm2, if it hasn't finished yet*/ - if(ret.tree!=NULL){ + if(ret.tree != NULL && ret.front != NULL){ if(strcmp(argv[2], "dfs") == 0) { ret = dfs_online(data, ret.front, ret.tree, 100); } else if(strcmp(argv[2], "random_heuristic") == 0) { |