From 3333e0c5a1a8e39c74fb178ac124940844463520 Mon Sep 17 00:00:00 2001 From: Alexandre Jesus Date: Wed, 2 Nov 2016 21:39:39 +0000 Subject: Also update random generator on online --- src/main/online.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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 #include #include +#include #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) { -- cgit v1.2.3