-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
47 lines (41 loc) · 1.03 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include "../head/Digraph.h"
#include "../head/DepthFirstOrder.h"
using namespace std;
/**
* Unit tests the {@code DirectedEulerianCycle} data type.
*
* @param args the command-line arguments
*/
int main() {
string file = "/home/ace/AceDev/C++/algorithm/ch4/data/tinyDG.txt";
Digraph G(file);
DepthFirstOrder dfs(G);
cout << " v pre post" << endl;
cout << "------------------" << endl;
for (int v = 0; v < G.getV(); ++v) {
cout << v << " " << dfs.getpre(v) << " " << dfs.getpost(v) << endl;
}
cout << "Preorder: ";
auto t = dfs.getpre();
while (!t.empty()) {
auto k = t.front();
t.pop();
cout << k << " ";
}
cout << endl;
cout << "Postorder: ";
auto t2 = dfs.getpost();
while (!t2.empty()) {
auto k = t2.front();
t2.pop();
cout << k << " ";
}
cout << endl;
cout << "Reverse Postorder: ";
auto t3 = dfs.reversePost();
for (auto k: t3) {
cout << k << " ";
}
cout << endl;
}