我试图使用boost图库,并且当我尝试使用boost :: edge()时出现段错误。完整的代码可以here,但在这里,我做了一个最小的程序有同样的问题(我用“G ++ minimal.cpp”编译):boost :: edge引起段错误
#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邮件列表](http://news.gmane.org/gmane.comp.lib.boost.devel)上。 – Mankarse 2013-03-15 02:34:42