#include #include "Directed_acyclic_graph.h" using namespace std; int main() { Directed_acyclic_graph dag( 20 ); cout << "Hi!" << endl; try { dag.insert_edge( 50, 3 ); cout << "bad: throw illegal_argument() if argument outside 0, ..., n - 1" << endl; } catch ( illegal_argument e ) { cout << "good 1" << endl; } catch (...) { cout << "bad 1: throw illegal_argument() if argument outside 0, ..., n - 1" << endl; } try { dag.insert_edge( 3, 50 ); cout << "bad: throw illegal_argument() if argument outside 0, ..., n - 1" << endl; } catch ( illegal_argument e ) { cout << "good 2" << endl; } catch (...) { cout << "bad 2: throw illegal_argument() if argument outside 0, ..., n - 1" << endl; } try { dag.set_priority( 50, 3.5 ); cout << "bad: throw illegal_argument() if argument outside 0, ..., n - 1" << endl; } catch ( illegal_argument e ) { cout << "good 3" << endl; } catch (...) { cout << "bad 3: throw illegal_argument() if argument outside 0, ..., n - 1" << endl; } if ( dag.set_priority( 3, 5 ) ) { cout << "bad 4: you have to check that the priority exits" << endl; } else { cout << "good 4" << endl; } if ( !( dag.insert_edge( 19, 18 ) && dag.insert_edge( 18, 17 ) && dag.insert_edge( 17, 16 ) && dag.insert_edge( 17, 13 ) && dag.insert_edge( 16, 15 ) && dag.insert_edge( 15, 12 ) && dag.insert_edge( 12, 11 ) && dag.insert_edge( 11, 10 ) && dag.insert_edge( 13, 10 ) && dag.insert_edge( 10, 9 ) && dag.insert_edge( 10, 8 ) && dag.insert_edge( 9, 7 ) && dag.insert_edge( 8, 7 ) && dag.insert_edge( 7, 5 ) ) ) { cout << "bad 5: all these insertions should have worked" << endl; } else { cout << "good 5" << endl; } if ( dag.insert_edge( 17, 13 ) ) { cout << "bad 6: check whether an edge already exists between two vertices" << endl; } else { cout << "good 6" << endl; } if ( dag.insert_edge( 5, 19 ) ) { cout << "bad 7: check whether an edge already exists between two vertices" << endl; } else { cout << "good 7" << endl; } dag.topological_sort(); cout << endl; dag.set_priority( 16, 0.3 ); dag.set_priority( 8, 29.3 ); dag.topological_sort(); cout << endl; return 0; }