当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::DOTshape方法代码示例

本文整理汇总了C++中node::Ptr::DOTshape方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::DOTshape方法的具体用法?C++ Ptr::DOTshape怎么用?C++ Ptr::DOTshape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在node::Ptr的用法示例。


在下文中一共展示了Ptr::DOTshape方法的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;
}
开发者ID:cuviper,项目名称:dyninst,代码行数:80,代码来源:DOT.C


注:本文中的node::Ptr::DOTshape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。