为什么我不能编译以下简单的应用程序.如果我将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;
}
Run Code Online (Sandbox Code Playgroud)
write_graphviz需要vertex_id属性来显示顶点标识符标签.的adjacency_list使用listS作为顶点容器不自动提供该vertex_id属性.这种行为是有道理的,因为在链表中,没有可用于唯一标识元素的键或索引.请记住,链表既不是随机访问序列,也不是关联容器.
您要么必须提供自己的vertex_id属性getter,要么使用具有固有vertex_id属性的顶点容器.
| 归档时间: |
|
| 查看次数: |
583 次 |
| 最近记录: |