为什么我不能将 boost graph write_graphviz 与 OutEdgeList=listS 和 VertexList=listS 一起使用
为什么我无法编译以下简单的应用程序。如果我将 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;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
write_graphviz
需要vertex_id
属性来显示顶点标识符标签。使用listS
作为顶点容器的adjacency_list
不会自动提供此vertex_id
属性。这种行为是有道理的,因为在链表中,不存在可用于唯一标识元素的键或索引之类的东西。请记住,链表既不是随机访问序列,也不是关联容器。您必须提供自己的
vertex_id
属性 getter,或者使用具有固有vertex_id
属性的顶点容器。write_graphviz
needs thevertex_id
property to display vertex identifier labels. Anadjacency_list
that useslistS
as the vertex container does not automatically provide thisvertex_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.You'll either have to supply your own
vertex_id
property getter, or use a vertex container that has an inherentvertex_id
property.