【问题标题】:Why can't I use boost graph write_graphviz with OutEdgeList=listS and VertexList=listS为什么我不能用 OutEdgeList=listS 和 Vertex List=listS 使用 boost graph write graphviz
【发布时间】:2011-08-12 11:37:23
【问题描述】:

为什么我不能编译下面这个简单的应用程序。如果我将 listS 更改为 vecS ,一切都会正常工作。 (我使用的是 boost 1.46.1 和 gcc 4.4.5)

#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>

int main(int argc, const char *argv[]) {
    boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS > g;

    boost::write_graphviz(std::cout, g);

    return 0;
}

【问题讨论】:

    标签: boost boost-graph


    【解决方案1】:

    write_graphviz 需要vertex_id 属性来显示顶点标识符标签。使用listS 作为顶点容器的adjacency_list 不会自动提供此vertex_id 属性。这种行为是有道理的,因为在链表中,没有可用于唯一标识元素的键或索引之类的东西。请记住,链表既不是随机访问序列,也不是关联容器。

    您要么必须提供自己的 vertex_id 属性获取器,要么使用具有固有 vertex_id 属性的顶点容器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 2020-04-23
      • 2013-11-30
      • 2021-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多