C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 使用graphviz绘制自定义BGL图大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是Boost图库的新手,我尝试使用graphviz绘制图形.

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/utility.hpp>                // for boost::tie
#include <iostream>
#include <utility>                          // for std::pair

using namespace boost;
using namespace std;

class V {};
class C {};

void draw_test(){
    typedef boost::adjacency_list<boost::listS,boost::listS,boost::bidirectionalS,V,C > MyGraph;
        typedef boost::graph_Traits<MyGraph>::vertex_descriptor vertex_descriptor;
    MyGraph g;
    vertex_descriptor a = add_vertex(V(),g);
    vertex_descriptor b = add_vertex(V(),g);
    add_edge(a,b,g);
    write_graphviz(std::cout,g);
}

int main() {
    draw_test();

    return 0;
}

但我得到以下错误

http://pastebin.com/KmTyyUHh

我会非常感谢任何帮助

解决方法

您可以在此问题中找到完全相同的问题( 1,2).问题是write_graphviz需要一个顶点索引属性映射(与许多其他Boost.Graph函数一样).认情况下,listS作为其VertexList的adjacency_list没有.除非你真的需要listS,否则只需在你的第二个模板参数中使用vecs.您可以在第一个链接答案中找到的另一个替代方法是创建并初始化外部顶点索引属性映射,然后使用write_graphviz的重载,允许您显式传递它.当您需要在图表中使用listS或setS时,这对于大量算法非常有用.

大佬总结

以上是大佬教程为你收集整理的c – 使用graphviz绘制自定义BGL图全部内容,希望文章能够帮你解决c – 使用graphviz绘制自定义BGL图所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。