1 #ifndef _SIMPLE_DIRECTED_GRAPH_H_
2 #define _SIMPLE_DIRECTED_GRAPH_H_
57 sprintf(buf,
"%p",
this);
64 std::set<SimpleDirectedGraphNode *>
_succs;
66 std::set<SimpleDirectedGraphNode *>
_preds;
103 return _nodes.count(node) > 0;
112 std::set<SimpleDirectedGraphNode *>::iterator i;
115 std::cout <<
":" << std::endl;
116 std::set<SimpleDirectedGraphNode *> succs = (*i)->getSuccessors();
117 std::set<SimpleDirectedGraphNode *>::iterator j;
118 for (j = succs.begin(); j != succs.end(); j++) {
119 std::cout <<
" succ: ";
121 std::cout << std::endl;
123 std::set<SimpleDirectedGraphNode *> preds = (*i)->getPredecessors();
124 for (j = preds.begin(); j != preds.end(); j++) {
125 std::cout <<
" pred: ";
127 std::cout << std::endl;
129 std::cout << std::endl;
135 std::ofstream f(filename);
137 f <<
"digraph \"G" << filename <<
"\" {" << std::endl;
139 std::set<SimpleDirectedGraphNode *>::iterator i;
143 sprintf(buf,
"%p", d);
144 f <<
"\"" << buf <<
"\" [label = \"";
146 f <<
"\"];" << std::endl;
152 std::set<SimpleDirectedGraphNode *> succs = d1->
getSuccessors();
153 std::set<SimpleDirectedGraphNode *>::iterator j;
154 for (j = succs.begin(); j != succs.end(); j++) {
160 sprintf(buf1,
"%p", d1);
161 sprintf(buf2,
"%p", d2);
163 f <<
"\"" << buf1 <<
"\" -> \"" << buf2 <<
"\";" << std::endl;
167 f <<
"}" << std::endl;
182 std::set<SimpleDirectedGraphNode *> reachables;
183 std::stack<SimpleDirectedGraphNode *> remaining;
185 remaining.push(start);
188 while (remaining.size() != 0) {
195 if (reachables.count(curr) == 0) {
196 reachables.insert(curr);
200 std::set<SimpleDirectedGraphNode *> children;
215 std::set<SimpleDirectedGraphNode *>::iterator i;
216 for (i = children.begin(); i != children.end(); i++) {
237 std::set<SimpleDirectedGraphNode *>
_nodes;