[Boost Graph Library] Problem with a simple undirected_dfs example

Hi, I'm trying to get a simple undirected_dfs example to work. The aim is simple, to create an undirected graph and print its nodes in DFS order. Here's my code: ///////////////////////////////////////////////////////////////////////////////////// #include <boost/graph/adjacency_list.hpp> #include <boost/graph/undirected_dfs.hpp> #include <iostream> using namespace std; typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS> MyGraph; typedef boost::graph_traits<MyGraph>::vertex_descriptor MyVertex; typedef boost::graph_traits<MyGraph>::edge_descriptor MyEdge; class MyVisitor : public boost::default_dfs_visitor { public: void discover_vertex(MyVertex v, const MyGraph& g) const { cerr << v << endl; } }; int main() { MyGraph g; boost::add_edge(0, 1, g); boost::add_edge(0, 2, g); boost::add_edge(1, 3, g); MyVisitor vis; boost::undirected_dfs(g, boost::visitor(vis)); return 0; } ///////////////////////////////////////////////////////////////////////////////////// I get the following errors which just make no sense to me: ///////////////////////////////////////////////////////////////////////////////////// Error 1 error C2780: 'void boost::put(T Bundle::* ,boost::adjacency_list<OutEdgeListS,VertexListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS> &,const Key &,const T &)' : expects 4 arguments - 3 provided d:\boost\boost\graph\undirected_dfs.hpp 149 Error 2 error C2780: 'void boost::put(Property,boost::adj_list_helper<Config,Base> &,const Key &,const Value &)' : expects 4 arguments - 3 provided d:\boost\boost\graph\undirected_dfs.hpp 149 Error 3 error C2784: 'void boost::put(const boost::put_get_helper<Reference,PropertyMap> &,K,const V &)' : could not deduce template argument for 'const boost::put_get_helper<Reference,PropertyMap> &' from 'boost::detail::error_property_not_found' d:\boost\boost\graph\undirected_dfs.hpp 149 Error 4 error C2784: 'void boost::put(const boost::writable_property_map_archetype<KeyArchetype,ValueArchetype> &,const writable_property_map_archetype<KeyArchetype,ValueArchetype>::key_type &,const writable_property_map_archetype<KeyArchetype,ValueArchetype>::value_type &)' : could not deduce template argument for 'const boost::writable_property_map_archetype<KeyArchetype,ValueArchetype> &' from 'boost::detail::error_property_not_found' d:\boost\boost\graph\undirected_dfs.hpp 149 Error 5 error C2784: 'void put(T *,ptrdiff_t,const V &)' : could not deduce template argument for 'T *' from 'boost::detail::error_property_not_found' d:\boost\boost\graph\undirected_dfs.hpp 149 ///////////////////////////////////////////////////////////////////////////////////// What am I doing wrong? How do I get to print nodes in DFS order? I'm on VC++ 2008 Express Edition. I have looked at the undirected_dfs example given here: <http://www.boost.org/doc/libs/1_35_0/libs/graph/example/undirected_dfs.cpp> That code seems to be trying to achieve something else. TIA, ~ash -- Groucho Marx - "A hospital bed is a parked taxi with the meter running."

On Thu, Jul 24, 2008 at 10:14 PM, Ashwin N <ashwin.n@gmail.com> wrote:
Hi,
I'm trying to get a simple undirected_dfs example to work. The aim is simple, to create an undirected graph and print its nodes in DFS order. Here's my code:
<snip>
MyGraph g; boost::add_edge(0, 1, g); boost::add_edge(0, 2, g); boost::add_edge(1, 3, g);
MyVisitor vis; boost::undirected_dfs(g, boost::visitor(vis));
<snip>
What am I doing wrong? How do I get to print nodes in DFS order? I'm on VC++ 2008 Express Edition.
The documentation for undirected_dfs (http://www.boost.org/doc/libs/1_35_0/libs/graph/doc/undirected_dfs.html) lists all of the expected parameters for undirected_dfs. You haven't provided the edge_color_map parameter, which is required. Depending on what you want to do, you might need to override the defaults on other parameters as well. If you just want to print nodes in DFS order, I'd suggest using depth_first_search (http://www.boost.org/doc/libs/1_35_0/libs/graph/doc/depth_first_search.html), which you can call by passing just a graph and a visitor, and works just fine on undirected graphs. Regards, Aaron
participants (2)
-
Aaron Windsor
-
Ashwin N