diff --git a/graph/graph.cpp b/graph/graph.cpp index ebdfeb9c6774d15b200c7c87ac39f077f80b5db1..0b4982b189dcbefb974e41eb0282118e30a49847 100644 --- a/graph/graph.cpp +++ b/graph/graph.cpp @@ -1080,6 +1080,11 @@ class Output { num_edges_++; } + // Check whether edge exists: + bool edge_exists(int from, int to) const { + return graph_->edge_exists(from, to); + } + // Close output files: void close_files() { for(int i = 0; i < num_files_; i++) { @@ -1840,6 +1845,7 @@ void gen_graph_u_a(int n, int k, output_t out, gsize_t gsize, bool acyclic) { // Skip loops: if(node1 == node2) continue; + // Make edge pointing towards the greater node: if(node1 > node2) { int swap = node1; @@ -1848,17 +1854,7 @@ void gen_graph_u_a(int n, int k, output_t out, gsize_t gsize, bool acyclic) { } // Because we changed edges, duplicates are possible: - bool duplicate = false; - for(int j = 0; j < i; j++) { - int n1 = a1[j % p1]; - int n2 = a2[j % p2]; - if((node1 == n1 && node2 == n2) || - (node1 == n2 && node2 == n1)) { - duplicate = true; - break; - } - } - if(duplicate) + if(out->edge_exists(node1, node2)) continue; } @@ -2317,5 +2313,6 @@ int main(int argc, str_t argv[]) time(&end_time); int seconds = (int) difftime(end_time, start_time); std::cout << " Elapsed time: " << seconds << "s\n"; + std::cout << "\n"; }