-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_pearce_not_recursive.cpp
54 lines (44 loc) · 1.67 KB
/
main_pearce_not_recursive.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
#include "my_pearce_not_recursive.cpp"
#include "include_and_types.cpp"
#include <boost/property_map/dynamic_property_map.hpp>
#include <boost/graph/graphml.hpp>
#include <boost/property_map/dynamic_property_map.hpp>
using namespace boost;
int main(int, char*[])
{
/*This is an example of how to modify this code for describing a graph "by hand" without using graphml parser and
stdin*/
/*typedef std::pair<int, int> Edge;
const int num_nodes = 8;
enum nodes { A, B, C, D, E, F, G, H, I, L, M, N};
char name[] = "ABCDEFGHILMN";
Edge edge_array[] = { Edge(A, B),
Edge(B, C), Edge(B, H),
Edge(C, D), Edge(C, G),
Edge(D, E),
Edge(E, F), Edge(E, C),
Edge(G, F), Edge(G, D),
Edge(H, A), Edge(H, G),
Edge(I, L),
Edge(M, N), Edge(N, M)
};
int num_arcs = sizeof(edge_array) / sizeof(Edge);
Graph g(edge_array, edge_array + num_arcs, num_nodes);*/
//Reading graph from stdin
Graph g;
dynamic_properties dp;
read_graphml(std::cin, g, dp);
//Graph printing
std::cout << "A directed graph:" << std::endl;
print_graph(g, get(vertex_index,g));
std::cout << std::endl;
//Instantiation of the PearceNR class object
PearceNR <typeBool, typeInt> pearcenr(&g);
std::vector<int>* rindex = pearcenr.pearce_not_recursive_scc();
//Results printing
IndexMap index=get(vertex_index,g);
for (int i = 0; i != num_vertices(g); ++i){
std::cout << index[i] << " -> " << (*rindex)[i] << std::endl;
}
return 0;
}