I'm struggling to implement a simple boost::graph. I've tried to read all the documentation I can find and examples etc...
Here is my code (copied from other examples on StackOverflow)
The vertex:
class customvertex
{
public:
double some_member;
};
The Visitor:
class MyVisitor : public boost::default_dfs_visitor
{
public:
void discover_vertex(MyGraphVertex v, const MyGraph& g) const
{
std::cout << v << std::endl;
return;
}
};
The typedef declaration:
typedef boost::adjacency_list<boost::vecS,boost::vecS,boost::undirectedS, customvertex> MyGraph;
typedef boost::graph_traits<MyGraph>::vertex_descriptor MyGraphVertex;
The code that causes a problem:
MyGraph theGraph;
customvertex a;
MyGraphVertex vert_a = boost::add_vertex(a, theGraph);
customvertex b;
MyGraphVertex vert_b = boost::add_vertex(b, theGraph);
boost::add_edge(vert_a , vert_b, theGraph);
MyVisitor vis;
boost::depth_first_search(theGraph, boost::visitor(MyVisitor()));
The final call to depth_first_search causes the compiler to throw out a 112 line cascading error.
The concepts seem to be IncidenceGraphConcept and MultiPassInputIterator
The key parts seem to be:
1> T:\boost\boost_1_47_0\boost/concept/detail/msvc.hpp(23) : while compiling class template member function 'void boost::concepts::check<Model>::failed(Model *)'
1> with
1> [
1> Model=boost::SignedInteger<int>
1> ]
1> T:\boost\boost_1_47_0\boost/graph/depth_first_search.hpp(83) : see reference to function template instantiation 'void boost::function_requires<boost::concepts::IncidenceGraphConcept<G>>(Model *)' being compiled
1> with
1> [
1> G=MyGraph,
1> Model=boost::concepts::IncidenceGraphConcept<MyGraph>
1> ]
1> T:\boost\boost_1_47_0\boost/graph/depth_first_search.hpp(202) : see reference to function template instantiation 'void boost::detail::depth_first_visit_impl<VertexListGraph,DFSVisitor,ColorMap,boost::detail::nontruth2>(const IncidenceGraph &,unsigned int,DFSVisitor &,ColorMap,TerminatorFunc)' being compiled
1> with
1> [
1> VertexListGraph=MyGraph,
1> DFSVisitor=const MyVisitor,
1> ColorMap=boost::shared_array_property_map<boost::default_color_type,boost::vec_adj_list_vertex_id_map<boost::property<boost::vertex_bundle_t,customvertex>,unsigned int>>,
1> IncidenceGraph=MyGraph,
1> TerminatorFunc=boost::detail::nontruth2
1> ]
Any and all help most appreciated. I'm sure I'm missing something simple and I can usually figure it out from examples. I think boost::graph looks great, perfect for what I need, but a bit more documentation......
I'm reasonably experienced with template programming but I've spent too many hours on this now, time to ask for help!