Hi. I am having a problem with depth_first_search. The thing I do different is that I do not put any info in a property map and I do not want to bother myself with colormaps etc. The application code does: Graph g; pass2_visitor vis; depth_first_search(g,boost::visitor(vis)); But I get a compilation error, saying that it can not find a suitable operator+ in the property_map... See attached files for complete example. Grateful for all help! (I am running from HEAD on sourceforge cvs ) Regards Peter Aronsson -- _________________________________________________________________ / Peter Aronsson, Phd Student at PELAB (Programming Environments \ | Laboratory ) Department for Computer & Information Science | | Linköping University, Sweden | |=================================================================| | petar@ida.liu.se , phone +46 (0)13-28 1737 Room 3B:490 | \_________________________________________________________________/ #include "tg.hpp" int main() { TaskGraph g; pass2_visitor vis; depth_first_search(g,boost::visitor(vis)); } #ifndef _TASKGRAPH_H #define _TASKGRAPH_H #include <boost/config.hpp> #include <iostream> // for std::cout #include <utility> // for std::pair #include <algorithm> // for std::for_each #include <boost/utility.hpp> // for boost::tie #include <boost/graph/graph_traits.hpp> // for boost::graph_traits #include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_iterator.hpp> #include <boost/graph/graphviz.hpp> #include <boost/graph/depth_first_search.hpp> //Task graph types using namespace std; using boost::tie; struct vertex_execcost_t { typedef boost::vertex_property_tag kind; }; struct vertex_unique_id_t { typedef boost::vertex_property_tag kind; }; struct edge_result_set_t { typedef boost::edge_property_tag kind; }; typedef boost::property<boost::vertex_name_t,string, boost::property<vertex_execcost_t,float, boost::property<vertex_unique_id_t, int > > > VertexProperty; typedef boost::property<boost::edge_weight_t, int > EdgeProperty; typedef boost::adjacency_list<boost::listS, boost::listS, boost::bidirectionalS, VertexProperty, EdgeProperty> TaskGraph; typedef boost::graph_traits<TaskGraph>::vertex_descriptor VertexID; class pass2_visitor : public boost::default_dfs_visitor { public: pass2_visitor(/* initialize containers to store stuff in*/) { }; template <typename Vertex, typename Graph> void discover_vertex(Vertex u, const Graph & g) const { // Do some stuff }; }; #endif
Peter Aronsson wrote:
Hi. I am having a problem with depth_first_search. The thing I do different is that I do not put any info in a property map and I do not want to bother myself with colormaps etc.
The application code does:
Graph g; pass2_visitor vis;
depth_first_search(g,boost::visitor(vis));
But I get a compilation error, saying that it can not find a suitable operator+ in the property_map...
Well, dfs need color map for its operation. You did not provide any, so it tried to use default color map, using std::vector and vertex indices. But, your graph also does not provide vertex_index_t property, so you get the error. When I use: typedef boost::property<boost::vertex_name_t,string, boost::property<vertex_execcost_t,float, boost::property<vertex_unique_id_t, int, boost::property<boost::vertex_index_t, int> > > > VertexProperty; your example compiles. However, for your example to work, you also need to manually iterate over all vertices and assign the vertex_index property. That's not nice, but I don't know better way. - Volodya
Actually, I now found that the problem is when having listS as adjacency lists. The same compilation error can be produced by changing vecS to listS in the dfs-example.cpp file. Perhaps a bug? Regards Peter Aronsson -- _________________________________________________________________ / Peter Aronsson, Phd Student at PELAB (Programming Environments \ | Laboratory ) Department for Computer & Information Science | | Linköping University, Sweden | |=================================================================| | petar@ida.liu.se , phone +46 (0)13-28 1737 Room 3B:490 | \_________________________________________________________________/
Peter Aronsson wrote:
Actually, I now found that the problem is when having listS as adjacency lists.
Yes, when you have vecS for vertex storage, the vertex_index_t property is automatically defined.
The same compilation error can be produced by changing vecS to listS in the dfs-example.cpp file.
Perhaps a bug?
It's more like design issue. Would be nice to have automatic vertex_index_t for listS but nobody yet implemented this, and even has not decided how this can be done. - Volodya
Vladimir Prus wrote:
Peter Aronsson wrote:
Actually, I now found that the problem is when having listS as adjacency lists.
Yes, when you have vecS for vertex storage, the vertex_index_t property is automatically defined.
The same compilation error can be produced by changing vecS to listS in the dfs-example.cpp file.
Perhaps a bug?
It's more like design issue. Would be nice to have automatic vertex_index_t for listS but nobody yet implemented this, and even has not decided how this can be done.
Yes your right. I guess I have to live with your proposed solution for now. Thank you for the help. Regards Peter Aronsson -- _________________________________________________________________ / Peter Aronsson, Phd Student at PELAB (Programming Environments \ | Laboratory ) Department for Computer & Information Science | | Linköping University, Sweden | |=================================================================| | petar@ida.liu.se , phone +46 (0)13-28 1737 Room 3B:490 | \_________________________________________________________________/
participants (2)
-
Peter Aronsson
-
Vladimir Prus