Go to the documentation of this file.00001 #ifndef wali_graph__MY_GRAPH_H_
00002 #define wali_graph__MY_GRAPH_H_
00003
00004 #include <set>
00005 #include <vector>
00006 #include <list>
00007 #include <map>
00008 using namespace std;
00009
00010 namespace wali {
00011
00012 namespace graph {
00013
00014 struct ActionFunctor {
00015 ActionFunctor() { }
00016 virtual ~ActionFunctor() { }
00017 virtual void operator() (long int n) = 0;
00018 };
00019
00020 class Node {
00021 public:
00022 set<int> edges[2];
00023 bool visited;
00024 int scc;
00025 int bfs;
00026 Node() {
00027 visited = false;
00028 scc = 0;
00029 bfs = 0;
00030 }
00031 Node(const Node &n) : visited(n.visited), scc(n.scc), bfs(n.bfs) {
00032 edges[0] = n.edges[0];
00033 edges[1] = n.edges[1];
00034 }
00035 };
00036
00037 struct AssignSCCActionFunctor;
00038
00039 class Graph {
00040 friend struct AssignSCCActionFunctor;
00041
00042 vector<Node> nodes;
00043 map<long int, long int> env_to_node;
00044
00045
00046 public:
00047 void addEdge(int s, int t);
00048 int runSCCdecomposition();
00049
00050 size_t getNnodes();
00051 int getSccNumber(int n);
00052 int getBfsNumber(int n);
00053
00054 private:
00055 inline long int create_node(int n);
00056 void dfs(long node, int direction, ActionFunctor &action);
00057 };
00058
00059 }
00060
00061 }
00062
00063 #endif // wali_graph__MY_GRAPH_H_