-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.cpp
57 lines (45 loc) · 1.48 KB
/
test.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
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <string>
#include <vector>
#include "SCC.hpp"
using namespace std;
void print(const DiGraph& g, vector<DiGraph>& scc){
// Print out the graph
print_graph(g, cout);
cout << "Components: " << scc.size() << endl << endl;
// Print found components
vector<DiGraph>::iterator it;
int i;
for(i = 1, it = scc.begin(); it != scc.end(); ++it, ++i) {
cout << "Component: " << i << endl;
print_graph(*it, cout);
cout << endl << endl;
}
}
void test_tarjan(const DiGraph& g, bool verbose){
vector<DiGraph> scc = tarjan_scc(g);
if(verbose) print(g, scc);
}
void test_nuutila1(const DiGraph& g, bool verbose){
vector<DiGraph> scc = nuutila1_scc(g);
if(verbose) print(g, scc);
}
void test_nuutila2(const DiGraph& g, bool verbose){
vector<int> scc = nuutila2_scc(g);
if(verbose) cout << "Components: " << scc.size() << endl << endl;
}
void test_pearce1(const DiGraph& g, bool verbose){
vector<int> scc = pearce1_scc(g);
std::set<int> components(scc.begin(), scc.end());
if(verbose) cout << "Components: " << components.size() << endl << endl;
}
void test_pearce2(const DiGraph& g, bool verbose){
vector<int> scc = pearce2_scc(g);
std::set<int> components(scc.begin(), scc.end());
if(verbose) cout << "Components: " << components.size() << endl << endl;
}
int main(int argc, char** argv){
// Generated random graph
DiGraph g = rand_graph(20, 20, 151);
test_pearce2(g, true);
}