128 std::cout <<
"Testing for graph 1\n";
137 std::vector<int> ans_1 = graph::topological_sort::topologicalSort(graph1);
138 std::vector<int> expected_1 = {5, 4, 2, 3, 1, 0};
139 std::cout <<
"Topological Sorting Order: ";
140 for (
int i : ans_1) {
141 std::cout << i <<
" ";
144 assert(ans_1 == expected_1);
145 std::cout <<
"Test Passed\n\n";
148 std::cout <<
"Testing for graph 2\n";
157 std::vector<int> ans_2 = graph::topological_sort::topologicalSort(graph2);
158 std::vector<int> expected_2 = {0, 1, 2, 4, 3};
159 std::cout <<
"Topological Sorting Order: ";
160 for (
int i : ans_2) {
161 std::cout << i <<
" ";
164 assert(ans_2 == expected_2);
165 std::cout <<
"Test Passed\n\n";
168 std::cout <<
"Testing for graph 3\n";
175 graph::topological_sort::topologicalSort(graph3);
176 }
catch (std::invalid_argument& err) {
177 assert(std::string(err.what()) ==
"cycle detected in graph");
179 std::cout <<
"Test Passed\n";