本文整理汇总了C++中node::Ptr::DOTrank方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::DOTrank方法的具体用法?C++ Ptr::DOTrank怎么用?C++ Ptr::DOTrank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node::Ptr
的用法示例。
在下文中一共展示了Ptr::DOTrank方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printDOT
bool Graph::printDOT(const std::string& fileName) {
FILE *file = fopen(fileName.c_str(), "w");
if (file == NULL) {
return false;
}
fprintf(file, "digraph G {\n");
NodeSet visited;
std::queue<Node::Ptr> worklist;
NodeIterator entryBegin, entryEnd;
entryNodes(entryBegin, entryEnd);
// Initialize visitor worklist
for (NodeIterator iter = entryBegin; iter != entryEnd; ++iter) {
worklist.push(*iter);
}
// Put the entry nodes on their own (minimum) rank
fprintf(file, " { rank = min;");
for (NodeIterator iter = entryBegin; iter != entryEnd; ++iter) {
fprintf(file, "\"%p\"; ", (*iter).get());
}
fprintf(file, "}\n");
NodeIterator exitBegin, exitEnd;
exitNodes(exitBegin, exitEnd);
// Put the entry nodes on their own (minimum) rank
fprintf(file, " { rank = max;");
for (NodeIterator iter = exitBegin; iter != exitEnd; ++iter) {
fprintf(file, "\"%p\"; ", (*iter).get());
}
fprintf(file, "}\n");
while (!worklist.empty()) {
Node::Ptr source = worklist.front();
worklist.pop();
//fprintf(stderr, "Considering node %s\n", source->format().c_str());
// We may have already treated this node...
if (visited.find(source) != visited.end()) {
//fprintf(stderr, "\t skipping previously visited node\n");
continue;
}
//fprintf(stderr, "\t inserting %s into visited set, %d elements pre-insert\n", source->format().c_str(), visited.size());
visited.insert(source);
fprintf(file, "\t%s\n", source->DOTshape().c_str());
fprintf(file, "\t%s\n", source->DOTrank().c_str());
fprintf(file, "\t\"%p\" [label=\"%s\"];\n",
source.get(), source->DOTname().c_str());
NodeIterator outBegin, outEnd;
source->outs(outBegin, outEnd);
for (; outBegin != outEnd; ++outBegin) {
Node::Ptr target = *outBegin;
if (!target->DOTinclude()) continue;
//fprintf(file, "\t %s -> %s;\n", source->DOTname().c_str(), target->DOTname().c_str());
fprintf(file, "\t \"%p\" -> \"%p\";\n", source.get(), target.get());
if (visited.find(target) == visited.end()) {
//fprintf(stderr, "\t\t adding child %s\n", target->format().c_str());
worklist.push(target);
}
else {
//fprintf(stderr, "\t\t skipping previously visited child %s\n",
//target->format().c_str());
}
}
}
fprintf(file, "}\n\n\n");
fclose(file);
return true;
}