1 #ifndef _SIMPLE_DIRECTED_GRAPH_H_
2 #define _SIMPLE_DIRECTED_GRAPH_H_
61 sprintf(buf,
"%p",
this);
69 std::set<SimpleDirectedGraphNode *>
_succs;
71 std::set<SimpleDirectedGraphNode *>
_preds;
106 if(from != NULL && to != NULL)
128 return _nodes.count(node) > 0;
137 std::set<SimpleDirectedGraphNode *>::iterator i;
140 std::cout <<
":" << std::endl;
141 std::set<SimpleDirectedGraphNode *> succs = (*i)->getSuccessors();
142 std::set<SimpleDirectedGraphNode *>::iterator j;
143 for (j = succs.begin(); j != succs.end(); j++) {
144 std::cout <<
" succ: ";
146 std::cout << std::endl;
148 std::set<SimpleDirectedGraphNode *> preds = (*i)->getPredecessors();
149 for (j = preds.begin(); j != preds.end(); j++) {
150 std::cout <<
" pred: ";
152 std::cout << std::endl;
154 std::cout << std::endl;
160 std::ofstream f(filename);
162 f <<
"digraph \"G" << filename <<
"\" {" << std::endl;
164 std::set<SimpleDirectedGraphNode *>::iterator i;
168 sprintf(buf,
"%p", d);
169 f <<
"\"" << buf <<
"\" [label = \"";
171 f <<
"\"];" << std::endl;
177 std::set<SimpleDirectedGraphNode *> succs = d1->
getSuccessors();
178 std::set<SimpleDirectedGraphNode *>::iterator j;
179 for (j = succs.begin(); j != succs.end(); j++) {
185 sprintf(buf1,
"%p", d1);
186 sprintf(buf2,
"%p", d2);
188 f <<
"\"" << buf1 <<
"\" -> \"" << buf2 <<
"\";" << std::endl;
192 f <<
"}" << std::endl;
207 std::set<SimpleDirectedGraphNode *> reachables;
208 std::stack<SimpleDirectedGraphNode *> remaining;
210 remaining.push(start);
213 while (remaining.size() != 0) {
220 if (reachables.count(curr) == 0) {
221 reachables.insert(curr);
225 std::set<SimpleDirectedGraphNode *> children;
240 std::set<SimpleDirectedGraphNode *>::iterator i;
241 for (i = children.begin(); i != children.end(); i++) {
262 std::set<SimpleDirectedGraphNode *>
_nodes;