【发布时间】:2013-03-03 15:27:16
【问题描述】:
我正在尝试使用 boost 图形库,当我尝试使用 boost::edge() 时遇到了段错误。完整代码可在here 获得,但在这里我制作了一个具有相同问题的最小程序(我正在使用“g++ minimum.cpp”进行编译):
#include<stdio.h>
#include<boost/graph/adjacency_list.hpp>
using namespace boost;
using namespace std;
typedef adjacency_list<> graph_t;
typedef graph_traits<graph_t>::edge_descriptor edge_descriptor;
int main(){
graph_t G;
//add_edge(1,3,G);
//remove_edge(1,3,G);
pair<edge_descriptor, bool> res = edge(1,3,G);
printf("G does %shave an edge 1->3\n", res.second ? "" : "not ");
return 0;
}
如果我取消注释 add_edge、remove_edge 行,则不会发生段错误,并且程序会打印预期的
G does not have an edge 1->3
但是有没有办法避免这种黑客行为?谢谢!
【问题讨论】:
-
这看起来很像一个错误。如果您无法在 Stackoverflow 上获得适当的回复,您可能需要在 Boost-Devel Mailing List 上提出。
标签: c++ boost boost-graph