为什么我不能将增强图write_graphviz与OutEdgeList = listS和VertexList = listS一起使用 [英] Why can't I use boost graph write_graphviz with OutEdgeList=listS and VertexList=listS

查看:52
本文介绍了为什么我不能将增强图write_graphviz与OutEdgeList = listS和VertexList = listS一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我不能编译以下简单应用程序.如果我将listS更改为vecS,则一切正常.(我正在使用boost 1.46.1和gcc 4.4.5)

Why can't I compile the following simple app. If I changes listS to vecS every thing works just fine. (I'am using boost 1.46.1 and 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;
}

推荐答案

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

write_graphviz needs the vertex_id property to display vertex identifier labels. An adjacency_list that uses listS as the vertex container does not automatically provide this vertex_id property. This behavior makes sense, because in a linked list, there is no such thing as a key or index that can be used to uniquely identify an element. Remember that a linked list is neither a random-access sequence, nor an associative container.

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

You'll either have to supply your own vertex_id property getter, or use a vertex container that has an inherent vertex_id property.

这篇关于为什么我不能将增强图write_graphviz与OutEdgeList = listS和VertexList = listS一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆