#include #include "Directed_acyclic_graph.h" #define SPEED int main() { int const TOTAL_LIMIT = 12; int const INDIVIDUAL_TESTS = 20; int const PRIORITY_CHANGES_FACTOR = 20; int sum; for ( int i = 4; i <= TOTAL_LIMIT; ++i ) { int n = 1 << i; Directed_acyclic_graph dag(n); for ( int j = i; j < 2*i; ++j ) { for ( int i = 0; i < n; ++i ) { int v1 = lrand48() % n; int v2 = lrand48() % n; #ifdef SPEED if ( dag.insert_edge( v1, v2 ) ) { ++sum; } #else std::cout << dag.insert_edge( v1, v2 ); #endif } #ifndef SPEED std::cout << std::endl; #endif for ( int k = 0; k < INDIVIDUAL_TESTS; ++k ) { int v1 = lrand48() % n; int v2 = lrand48() % n; #ifdef SPEED if ( dag.connected( v1, v2 ) ) { ++sum; } #else std::cout << dag.connected( v1, v2 ); #endif } #ifndef SPEED std::cout << std::endl; #endif for ( int k = 0; k < INDIVIDUAL_TESTS; ++k ) { for ( int m = 0; m < PRIORITY_CHANGES_FACTOR; ++m ) { int v1 = lrand48() % n; double pri = drand48() * n; dag.set_priority( v1, pri ); } dag.topological_sort(); #ifndef SPEED std::cout << std::endl; #endif } } #ifdef SPEED std::cout << std::endl; #endif } return 0; }