-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
35 lines (30 loc) · 831 Bytes
/
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
#include <iostream>
#include <queue>
#include "../head/GabowSCC.h"
using namespace std;
/**
* Unit tests the {@code TarjanSCC} data type.
*
* @param args the command-line arguments
*/
int main() {
string file = "/home/ace/AceDev/C++/algorithm/ch4/data/tinyDG.txt";
Digraph G(file);
GabowSCC scc(G);
// number of connected components
int m = scc.count_();
cout << m << " strong components" << endl;
// compute list of vertices in each strong component
vector<queue<int>> components(m);
for (int v = 0; v < G.getV(); ++v) {
components[scc.id_(v)].push(v);
}
// print results
for (int i = 0; i < m; ++i) {
while (!components[i].empty()) {
cout << components[i].front() << " ";
components[i].pop();
}
cout << endl;
}
}