Exemplo n.º 1
0
int main() {
    Node *root, *aux;
    int size, check = 1, number, temp, num1, num2;
    clock_t c2, c1;
    float _time;

    scanf("%s", input);
    transform_input();
    printf("(%s)\n", input);

    size = strlen(input);
    root = make_graph(0, size - 1);

    printf("Original Graph:\n");
    print_graph(root);
    printf("\n");

    printf("Start..\n");

    c1 = clock();
    root = reduce_graph(root, 0);
    c2 = clock();

    _time = (c2 - c1)*1000/CLOCKS_PER_SEC;

    printf("\n\nEnd!\n");
    printf("Reduced Graph:\n");
    print_graph(root);
    printf("\nTempo de redução: %dhs %dmin %dseg %dmiliseg\n\n", (((int) _time)/1000)/3600, ((((int) _time)/1000)%3600)/60, ((((int) _time)/1000)%3600)%60, ((int) _time) - (((int) _time)/1000)*1000);
    printf("\n");

    return 0;
}
Exemplo n.º 2
0
EdgeList generateEdgeList(int argc, char** argv, packed_edge** output){
    int log_numverts;
    int64_t nedges;
    packed_edge* result;
    log_numverts = 16; /* In base 2 */
    if (argc >= 2) log_numverts = atoi(argv[1]);
    make_graph(log_numverts, INT64_C(16) << log_numverts, 1, 2, &nedges, &result);
    printf("nedges=%ld before\n",nedges);
    //remove loops:
#if rmdup
    tic();
    packed_edge* end=thrust::remove_if(result, result+nedges, is_loop());
    //sort packed_edge twice:
    thrust::sort(result,end,pe_less1());
    thrust::sort(result,end,pe_less2());
    //nedges=(end-result);
    //printf("nedges=%d after loop\n",nedges);
    //remove duplicates:
    end=thrust::unique(result,end);
    cudaDeviceSynchronize();
    elapsed_time+=toc();
    printf("remove dup took %f ms\n", elapsed_time);
    //TEMP: reset elapsed time:
    elapsed_time=0;
    nedges=(end-result);
    printf("nedges=%ld after dup\n",nedges);
    //
#endif
    uusi::EdgeList el=graph500ToEdgeList((const packed_edge*)result,nedges);
    *output=result;
    return el;
}
Exemplo n.º 3
0
void test_dijkstra()
{
    // remember to insert edges both ways for an undirected graph
    Landscape landscape(5, 5);

    for (int yi = 0; yi < landscape.height; yi++) {
        for (int xi = 0; xi < landscape.width; xi++) {
            QPoint coords = QPoint(xi, yi);

            if (xi == 2) {
                landscape.setTile(coords, Tile::WATER_TILE);
            } else {
                landscape.setTile(coords, Tile::GRASS_TILE);
            }

            std::cout << "+" << landscape.getTile(coords).walkSpeed() << std::endl;
        }
    }
    adjacency_list_t adjacency_list = make_graph(landscape);

    std::vector<weight_t> min_distance;
    std::vector<vertex_t> previous;

    QPoint start(0, 0);
    QPoint end(4, 0);

    DijkstraComputePaths(landscape.coordsToIndex(start),
                         adjacency_list, min_distance, previous);

    std::cout << "Distance from 0,0 to 11,5: " << min_distance[landscape.coordsToIndex(end)] << std::endl;
    std::list<vertex_t> path = DijkstraGetShortestPathTo(landscape.coordsToIndex(end), previous);
    std::cout << "Path : ";
    std::copy(path.begin(), path.end(), std::ostream_iterator<vertex_t>(std::cout, " "));
    std::cout << std::endl;
}
Exemplo n.º 4
0
int main(int argc, char* argv[]) {
  int log_numverts;
  unsigned int start, time_taken;
  size_t i;
  int64_t nedges, actual_nedges;
  int64_t* result;

  log_numverts = 16; /* In base GRAPHGEN_INITIATOR_SIZE */
  if (argc >= 2) log_numverts = atoi(argv[1]);

  /* Start of graph generation timing */
#pragma mta fence
  start = mta_get_clock(0);

  double initiator[] = {.57, .19, .19, .05};
  make_graph(log_numverts, 8. * pow(2., log_numverts), 1, 2, initiator, &nedges, &result);

#pragma mta fence
  time_taken = mta_get_clock(start);
  /* End of graph generation timing */

  actual_nedges = 0;
#pragma mta block schedule
  for (i = 0; i < nedges; ++i) if (result[i * 2] != (int64_t)(-1)) ++actual_nedges;

  fprintf(stderr, "%" PRIu64 " edge%s generated and permuted in %fs (%f Medges/s)\n", actual_nedges, (actual_nedges == 1 ? "" : "s"), time_taken * mta_clock_period(), 1. * actual_nedges / time_taken * 1.e-6 / mta_clock_period());

  free(result);

  return 0;
}
Exemplo n.º 5
0
int main(int argc, char* argv[]) {
  Grappa::init(&argc, &argv);
  Grappa::run([]{
    LOG(INFO) << "starting...";
 
    tuple_graph tg;
    csr_graph unweighted_g;
    uint64_t N = (1L<<FLAGS_logN);

    uint64_t desired_nnz = FLAGS_nnz_factor * N;

    // results output
    DictOut resultd;

    double time;
    /*TODO SEED*/userseed = 10;
    TIME(time, 
      make_graph( FLAGS_logN, desired_nnz, userseed, userseed, &tg.nedge, &tg.edges );
    );
    LOG(INFO) << "make_graph: " << time;
    resultd.add( "make_graph_time", time );

    TIME(time,
      create_graph_from_edgelist(&tg, &unweighted_g);
    );
Exemplo n.º 6
0
Node* make_graph(int start, int end){
    /*
        Recursive function:
        It returns the root node
        of each subgraph
    */
    Node *node;
    int last_arg;
    char aux_int = 'x';

    last_arg = get_last_arg(start, end);

    if (input[start] == '(' && input[end] == ')' && end == get_pair(start)) {
        node = make_graph(start+1, end-1);
    }
    else if (input[start] == '[' && input[end] == ']' && end == get_pair(start)) {
        node = (Node*) malloc(sizeof(Node));
        node->type = '@';
        node->left = make_leaf(':');
        node->right = make_graph(start+1, end-1);
    }
    else if (last_arg == start || (input[start] >= 48 && input[start] <=57)) {
        if (input[start] >= 48 && input[start] <= 57)
            node = make_Nleaf(start,last_arg);
        else
            node = make_leaf(input[start]);
    }
    else {

        node = (Node*) malloc(sizeof(Node));
        node->type = '@';

        // if (input[end] == '+' || input[end] == '-'){
        //     node->left = make_leaf(input[end]);
        //     node->right = make_graph(start, end-1);
        // }
        // else {
            node->left = make_graph(start, last_arg-1);
            node->right = make_graph(last_arg, end);
        // }
    }

    return node;

}
Exemplo n.º 7
0
int main(void) {
  const unsigned max_size = 1000;
  unsigned graph[max_size][2];

  struct timeval tv;
  if (gettimeofday(&tv, NULL)) {
    return 1;
  }
  unsigned long long t = (unsigned long long)tv.tv_sec * 1000000 + tv.tv_usec;
  const int seed = (t >> 32) ^ t;

  srand(seed);
  unsigned size = rand() % max_size + 1;
  for (unsigned i = 0; i < size; ++i) {
    graph[i][0] = rand() % (size+1);
    graph[i][1] = rand() % (size+1);
  }

  struct node n1[max_size], n2[max_size];
  make_graph(size, graph, n1);
  make_graph(size, graph, n2);

  schorr_waite(n1);
  simple_traverse(n2);

  for (unsigned i = 0; i < size; ++i) {
    if (graph[i][0] == size) {
      assert(n1[i].l == NULL);
      assert(n2[i].l == NULL);
    } else {
      assert(n1[i].l == n1 + graph[i][0]);
      assert(n2[i].l == n2 + graph[i][0]);
    }
    if (graph[i][1] == size) {
      assert(n1[i].r == NULL);
      assert(n2[i].r == NULL);
    } else {
      assert(n1[i].r == n1 + graph[i][1]);
      assert(n2[i].r == n2 + graph[i][1]);
    }
    assert(n1[i].m == n2[i].m);
  }

  return 0;
}
Exemplo n.º 8
0
int main(int argc, char ** argv) {
  long n_nodes = (argc > 1 ? atol(argv[1]) : 1000);
  long n_edges = (argc > 2 ? atol(argv[2]) : 10000);
  assert(n_edges >= n_nodes - 1);
  assert(n_nodes > 1 || n_edges == 0);
  make_graph(n_nodes, n_edges);
  myth_create_join_many_ex(0, 0, visit_node, V, 0,
			   0, 0,             sizeof(node), 0,
			   n_nodes);
  printf("OK\n");
  return 0;
}
Exemplo n.º 9
0
int main(int argc, char* argv[])
{
    /* Start the timer */
    uglyTime(NULL);
    printf("\nQUBIC %.1f: greedy biclustering (compiled "__DATE__" "__TIME__")\n\n", VER);
    rows = cols = 0;

    /* get the program options defined in get_options.c */
    get_options(argc, argv);

    /*get the size of input expression matrix*/
    get_matrix_size(po->FP);
    progress("File %s contains %d genes by %d conditions", po -> FN, rows, cols);
    if (rows < 3 || cols < 3)
    {
        /*neither rows number nor cols number can be too small*/
        errAbort("Not enough genes or conditions to make inference");
    }
    genes = alloc2c(rows, LABEL_LEN);
    conds = alloc2c(cols, LABEL_LEN);

    /* Read in the gene names and condition names */
    read_labels(po -> FP);

    /* Read in the expression data */
    if (po->IS_DISCRETE)
        read_discrete(po -> FP);
    else
    {
        read_continuous(po -> FP);

        /* formatting rules */
        discretize(addSuffix(po->FN, ".rules"));
    }
    fclose(po->FP);

    /*we can do expansion by activate po->IS_SWITCH*/
    if (po->IS_SWITCH)
    {
        read_and_solve_blocks(po->FB, addSuffix(po->BN, ".expansion"));
    }
    else
    {
        /* formatted file */
        write_imported(addSuffix(po->FN, ".chars"));

        /* the file that stores all blocks */
        make_graph(addSuffix(po->FN, ".blocks"));
    }/* end of main else */
    free(po);
    return 0;
}
Exemplo n.º 10
0
 vector<int> findOrder(int numCourses, vector<pair<int, int> >& prerequisites) 
 {
 	vector<int> res;
 	vector<unordered_set<int> > graph;
 	graph = make_graph(numCourses, prerequisites);
 	vector<int> visited(numCourses, 0);   //0 unvisited, 1 being visited, 2 visited;
 	for (int i = 0; i < numCourses; ++i)
 	{
 		if (visited[i] == 2) continue;
 		if (!dfs(graph, visited, res, i)) return {};
 	}
 	reverse(res.begin(), res.end());
 	return res;
 }
Exemplo n.º 11
0
static void
create_graphs(Dt_t* chans)
{
    Dt_t* lp;
    Dtlink_t* l1;
    Dtlink_t* l2;
    channel* cp;

    for (l1 = dtflatten (chans); l1; l1 = dtlink(chans,l1)) {
	lp = ((chanItem*)l1)->chans;
	for (l2 = dtflatten (lp); l2; l2 = dtlink(lp,l2)) {
	    cp = (channel*)l2;
	    cp->G = make_graph (cp->cnt);
   	}
    }
}
Exemplo n.º 12
0
QVector<QPoint> Landscape::getPath(QPoint start, QPoint end) const
{
    std::vector<weight_t> min_distance;
    std::vector<vertex_t> previous;

    adjacency_list_t adj = make_graph(*this);
    DijkstraComputePaths(this->coordsToIndex(start), adj, min_distance, previous);
    std::list<vertex_t> path = DijkstraGetShortestPathTo(this->coordsToIndex(end), previous);

    if (min_distance[this->coordsToIndex(end)] > 2000000) {
        return QVector<QPoint>();
    }

    QVector<QPoint> retPath;
    foreach(vertex_t vx, path) {
        retPath.append(this->indexToCoords(vx));
    }
Exemplo n.º 13
0
int main(int argc, char* argv[]) {
  int log_numverts;
  double start, time_taken;
  int64_t nedges;
  packed_edge* result;

  log_numverts = 16; /* In base 2 */
  if (argc >= 2) log_numverts = atoi(argv[1]);

  /* Start of graph generation timing */
  start = get_time();
  make_graph(log_numverts, INT64_C(16) << log_numverts, 1, 2, &nedges, &result);
  time_taken = get_time() - start;
  /* End of graph generation timing */

  fprintf(stderr, "%" PRIu64 " edge%s generated in %fs (%f Medges/s)\n", nedges, (nedges == 1 ? "" : "s"), time_taken, 1. * nedges / time_taken * 1.e-6);

  free(result);

  return 0;
}
 bool canFinish(int numCourses, vector<pair<int, int>>& prerequisites) {
     //as the graph node value is int type, we use the node value to index 
     // the nodes, for non-int value, maybe key_to_index is needed 
     // also visited flags are accessed by node value
     // visited = true does not mean the cycle is detected!!
     // after all the adjacent nodes are dfsed, the onpath is set to 
     // false. then if the adjacent nodes is still onpath but now get
     // to be dfsed, cycle is detected!!
     
     //adjacent list is represneted by unordered_set<int>
     vector<unordered_set<int>> graph = make_graph(numCourses, prerequisites);
     vector<bool> onpath(numCourses, false), visited(numCourses, false);
     
     //loop the vertices to perform DFS
     for(int i = 0; i < numCourses; i++)
     {
         if (!visited[i] && dfs_cycle(graph, i, onpath, visited))
             return false; 
     }
     
     return true;
 }
Exemplo n.º 15
0
inline std::ostream& write_graphviz(std::ostream& ost,
                 const std::vector<std::vector<double> >& adj_matrix,
                 const size_t frequency=0,
                 const std::vector<std::string>& normal_input={},
                 const std::vector<std::string>& novel_input={})
{
    Graph graph = make_graph(adj_matrix);
    for (size_t i=0; i<normal_input.size(); ++i) {
        boost::put(boost::vertex_index1, graph,
                   boost::vertex(i, graph), normal_input[i]);
    }
    for (size_t i=0; i<novel_input.size(); ++i) {
        boost::put(boost::vertex_index2, graph,
                   boost::vertex(i, graph), novel_input[i]);
    }
    insert_graphattr(&graph, "frequency", frequency);
    boost::write_graphviz(ost, graph,
        make_double_writer(boost::get(boost::vertex_index1, graph), "normal",
                           boost::get(boost::vertex_index2, graph), "novel"),
        make_property_writer(boost::get(boost::edge_weight, graph), "weight"),
        boost::make_graph_attributes_writer(graph));
    return ost;
}
Exemplo n.º 16
0
 string alienOrder(vector<string>& words) {
     if (words.size() == 1) return words[0];
     graph g = make_graph(words);
     return toposort(g);
 }
Exemplo n.º 17
0
int main(void) {
  Graph g = make_graph();
  return 0;
}
Exemplo n.º 18
0
int
main (int argc, char **argv)
{
  int * restrict has_adj;
  int fd;
  int64_t desired_nedge;
  if (sizeof (int64_t) < 8) {
    fprintf (stderr, "No 64-bit support.\n");
    return EXIT_FAILURE;
  }

  if (argc > 1)
    get_options (argc, argv);

  nvtx_scale = 1L<<SCALE;

  init_random ();

  desired_nedge = nvtx_scale * edgefactor;
  /* Catch a few possible overflows. */
  assert (desired_nedge >= nvtx_scale);
  assert (desired_nedge >= edgefactor);


  if (VERBOSE) fprintf (stderr, "Generating edge list...");
  if (use_RMAT) {
    nedge = desired_nedge;
    IJ = xmalloc_large_ext (nedge * sizeof (*IJ));
    rmat_edgelist (IJ, nedge, SCALE, A, B, C);
  } else {
    make_graph(SCALE, desired_nedge, userseed, userseed, &nedge, (struct packed_edge**)(&IJ));
  }
  if (VERBOSE) fprintf (stderr, " done.\n");

  if (dumpname)
    fd = open (dumpname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
  else
    fd = 1;

  if (fd < 0) {
    fprintf (stderr, "Cannot open output file : %s\n",
	     (dumpname? dumpname : "stdout"));
    return EXIT_FAILURE;
  }

  write (fd, IJ, 2 * nedge * sizeof (*IJ));

  int buflen = strlen(dumpname) + strlen(".graph") + 1;
  char * graphname = (char *) malloc(buflen * sizeof(char));
  snprintf(graphname, buflen, "%s.graph", dumpname);

  FILE * file = fopen(graphname, "w");
  if(!file){
      fprintf (stderr, "Cannot open output file : %s\n",
  	     (graphname? graphname : "stdout"));
      return EXIT_FAILURE;
  }

  for (int64_t k = 0; k < nedge; ++k) {
    const int64_t i = get_v0_from_edge(&IJ[k]);
    const int64_t j = get_v1_from_edge(&IJ[k]);
    if (i != j)
      fprintf(file, "%" PRId64 " %" PRId64 "\n", i+1, j+1);
  }

  fclose(file);
  //close (fd);
  free(graphname);



  return EXIT_SUCCESS;
}
Exemplo n.º 19
0
void do_client_simulation() {
    char buf[256], buf2[256];
    int retval;
    FILE* f;

    sprintf(buf, "%s%s", infile_prefix, CONFIG_FILE);
    cc_config.defaults();
    read_config_file(true, buf);

    log_flags.init();
    sprintf(buf, "%s%s", outfile_prefix, "log_flags.xml");
    f = fopen(buf, "r");
    if (f) {
        MIOFILE mf;
        mf.init_file(f);
        XML_PARSER xp(&mf);
        xp.get_tag();   // skip open tag
        log_flags.parse(xp);
        fclose(f);
    }

    gstate.add_platform("client simulator");
    sprintf(buf, "%s%s", infile_prefix, STATE_FILE_NAME);
    if (!boinc_file_exists(buf)) {
        fprintf(stderr, "No client state file\n");
        exit(1);
    }
    retval = gstate.parse_state_file_aux(buf);
    if (retval) {
        fprintf(stderr, "state file parse error %d\n", retval);
        exit(1);
    }

    // if tasks have pending transfers, mark as completed
    //
    for (unsigned int i=0; i<gstate.results.size(); i++) {
        RESULT* rp = gstate.results[i];
        if (rp->state() < RESULT_FILES_DOWNLOADED) {
            rp->set_state(RESULT_FILES_DOWNLOADED, "init");
        } else if (rp->state() == RESULT_FILES_UPLOADING) {
            rp->set_state(RESULT_FILES_UPLOADED, "init");
        }
    }

    check_app_config(infile_prefix);
    show_app_config();
    cc_config.show();
    log_flags.show();

    sprintf(buf, "%s%s", infile_prefix, GLOBAL_PREFS_FILE_NAME);
    sprintf(buf2, "%s%s", infile_prefix, GLOBAL_PREFS_OVERRIDE_FILE);
    gstate.read_global_prefs(buf, buf2);
    fprintf(index_file,
        "<h3>Output files</h3>\n"
        "<a href=%s>Summary</a>\n"
        "<br><a href=%s>Log file</a>\n",
        SUMMARY_FNAME, LOG_FNAME
    );

    // fill in GPU device nums and OpenCL flags
    //
    for (int i=0; i<coprocs.n_rsc; i++) {
        COPROC& cp = coprocs.coprocs[i];
        for (int j=0; j<cp.count; j++) {
            cp.device_nums[j] = j;
            if (cp.have_opencl) {
                cp.instance_has_opencl[j] = true;
            }
        }
    }
    set_no_rsc_config();
    process_gpu_exclusions();

    get_app_params();
    if (!include_empty_projects) {
        cull_projects();
    }
    fprintf(summary_file, "--------------------------\n");

    int j=0;
    for (unsigned int i=0; i<gstate.projects.size(); i++) {
        gstate.projects[i]->index = j++;
    }

    clear_backoff();

    gstate.log_show_projects();
    gstate.set_ncpus();
    work_fetch.init();

    //set_initial_rec();

    rec_adjust_period = delta;

    gstate.request_work_fetch("init");
    simulate();

    sim_results.compute_figures_of_merit();

    sprintf(buf, "%s%s", outfile_prefix, RESULTS_DAT_FNAME);
    f = fopen(buf, "w");
    sim_results.print(f);
    fclose(f);
    sprintf(buf, "%s%s", outfile_prefix, RESULTS_TXT_FNAME);
    f = fopen(buf, "w");
    sim_results.print(f, true);
    fclose(f);

    fprintf(summary_file,
        "Simulation done.\n"
        "-------------------------\n"
        "Figures of merit:\n"
    );

    sim_results.print(summary_file, true);

    double cpu_time;
    boinc_calling_thread_cpu_time(cpu_time);
    fprintf(summary_file,
        "-------------------------\n"
        "Simulator CPU time: %f secs\n"
        "-------------------------\n"
        "Peak FLOPS: CPU %.2fG GPU %.2fG\n",
        cpu_time,
        cpu_peak_flops()/1e9,
        gpu_peak_flops()/1e9
    );
    print_project_results(summary_file);

    fclose(rec_file);
    make_graph("REC", "rec", 0);
}
Exemplo n.º 20
0
int main()
{
    int inword_toggle=0;
    char previous_char='\0';

    setlocale(LC_ALL,"hun_HU.iso88592");


    txt=fopen("test04.txt","r");

    if(txt==0)
    {
        printf("Error: %d",errno);
        return 0;
    }
    while((actual_char=fgetc(txt))!=EOF)
    {
        if(qerror()<0)
        {
            qerror();
            return -1;
        }
//        printf("%c",actual_char);
//        printf("\tvalue is=%d\n",actual_char);
        if(isalpha(actual_char))
        {
            letter++;
        }
        else
        {
            if(ifspace()==1)
            {
                space++;
            }
            if(ifnl()==1)
            {
                nl++;
            }
        }
        //sets inword_toggle to 1 if at start of word
        if((actual_char!=' ' && actual_char!='\n') && isspace(previous_char))
        {
            word++;
            inword_toggle=1;
        }
        //sets inword_toggle to 0 if at the end of a word
        if((actual_char==' ' || actual_char=='\n') && isalnum(previous_char))
        {
            inword_toggle=0;
//            printf("%d\n",wordletternum);
            lettersumarrayfiller();
//            printf("%d=%d\n",i,letternumsum[i]);

        }
        //adds one to wordletternum value if still in word or resets counter if not
        if(inword_toggle==1)
        {
            wordletternum++;
        }
        else
        {
            wordletternum=0;
        }
        previous_char=actual_char;
    }
    lettersumarrayfiller();
    fclose(txt);
    avrcalc();
    term_win_size();
    onepercent();

    printf("The number of letters: %5d\n",letter);
    printf("The number of words: %6d\n",word);
    printf("The number of spaces: %5d\n",space);
    printf("The number of new lines: %d\n",nl);
    printf("\n\n");

/*    for(i=0;i<ARRAYSIZE;i++)
    {
        if(letternumsum[i]!='\0')
        {
            printf("The number of %d letter words is=%d\n",i,letternumsum[i]);
        }
    }*/

    make_graph();
//    printf("terminal width is:%d",term_win_size());
//    printf("1 percent is:%.3f\n",onepercent());
//    printf("display size is %d\n",display_size());
    return 0;
}
Exemplo n.º 21
0
int main(int argc, char* argv[]) {
  struct timeval currentTime;
  gettimeofday(&currentTime, NULL);
  int seed = currentTime.tv_sec ^ currentTime.tv_usec;
  seed ^= seed >> 12;
  seed ^= seed << 25;
  seed ^= seed >> 27;

  FILE *fout;

  if (argc < 2 || argc > 10) {
      printError();
  }

  // define all the variables
  int log_numverts = -1;
  char * filename = "";
  long int numEdges;
  double start, time_taken, start_write, time_taken_write;
  int64_t nedges;
  packed_edge* result;
  int binary = 0; // set default to be not binary, normal tsv

  numEdges = 16;  // default 16
  fout = stdout;  // default the stdout

  int opt;
  while(optind < argc) {
    if ((opt = getopt(argc, argv, "+e:o:s:b")) != -1) {
      switch (opt) {
        case 'e':
            numEdges = atoi(optarg);
            break;
        case 'o':
            filename = optarg;
            fout = fopen(optarg, "wb");
            if (fout == NULL) {
              fprintf(stderr, "%s -- ", optarg);
              perror("fopen for write failed");
              exit(1);
            }
            break;
        case 's':
            seed = atoi(optarg);
            break;
        case 'b':
            binary = 1;
            break;
        default: 
            printError();
            break;
        }
    } else {
      if(argv[optind] == NULL) {
        printError();
      } else {
        log_numverts = atoi(argv[optind]); // In base 2
        optind++;
      }
    }
  }

  if( log_numverts < 0 ) {
    printError();
  }

  //Start of graph generation timing
  start = get_time();
  make_graph(log_numverts, numEdges << log_numverts, seed, seed, &nedges, &result);
  time_taken = get_time() - start;

  printf("For 2^%d\n", log_numverts);
  printf("\t%f seconds for making graph\n", time_taken);

  if (binary == 0) {
  // print to the file
    start_write = get_time();
    for (int i = 0; i < (numEdges << log_numverts); i++) {
      fprintf(fout, "%lu\t%lu\n", get_v0_from_edge(result + i), get_v1_from_edge(result + i));
    }
    time_taken_write = get_time() - start_write;
    printf("\t%f seconds for writing ascii version\n", time_taken_write);
  } else {
    // need to print binary
    start_write = get_time();
    for (int i = 0; i < (numEdges << log_numverts); i++) {
      uint32_t from = get_v0_from_edge(result + i);
      uint32_t to = get_v1_from_edge(result + i);
      // add the check for not exceed the uint32_t max
      fwrite((const void*) & from,sizeof(uint32_t),1,fout);
      fwrite((const void*) & to,sizeof(uint32_t),1,fout);
    }
    time_taken_write = get_time() - start_write;
    printf("\t%f seconds for writing binary version\n", time_taken_write);
  }

  int check_correctness;
  check_correctness = fclose(fout);
  if (check_correctness == EOF) {
    fprintf(stderr, "%s -- ", filename);
    perror("fclose failed");
    exit(1);
  }

  return 0;
}