I'm trying to use the boost graph library, and I'm getting a segfault when I try to use boost::edge(). The full code is available here, but here I've made a minimal program that has the same issue (I'm compiling with "g++ minimal.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;
}
If I uncomment the add_edge, remove_edge lines, The segfault does not occur, and the program prints the expected
G does not have an edge 1->3
but is there a way to avoid such hackery? Thanks!