2012/6/29 Jeremiah Willcock
On Fri, 29 Jun 2012, Joachim Faulhaber wrote:
Dear Jeremiah,
thank you for your answer. Unfortunately, it doesn't solve my problems. I admit, I am pretty much frustrated with BGL usability. Generally I am fond of boost and I recommend using it to my colleagues. But currently my experiences with BGL is very unsatisfactory. I hope there are solutions.
BGL can be quite frustrating to use, especially since diagnosis of errors is not always good. The trunk version should be better by a little bit, but it still does require some experience to track down errors.
2012/6/28 Jeremiah Willcock
: On Mon, 25 Jun 2012, Joachim Faulhaber wrote:
Hi,
When using visitors with the depth_first_search algorithm I can successfully compile and run this code:
[...]
The simplest way is probably to use associative_property_map; see lines 129-140 of
http://www.informatik.uni-koeln.de/scil/documentation/html/SteinerArborescen... for an example. You can also look at
http://boost.2283326.n4.nabble.com/BGL-dijkstra-shortest-paths-with-listS-td... for other places where associative_property_map can be used.
[...]
From your recommendation ...
The simplest way is probably to use associative_property_map; see lines 129-140 of
http://www.informatik.uni-koeln.de/scil/documentation/html/SteinerArborescen...
... I have tried to fix my example:
//========================================================= template<class Graph> class Visitor: public default_dfs_visitor { public: typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
void discover_vertex(Vertex v, const Graph& g)const {cout << v << " "; return;} };
struct Int{ Int(): _value(0){} Int(int val): _value(val){} int _value; };
void GLL_visit() { typedef adjacency_list
GraphLL; typedef graph_traits<GraphLL>::vertex_descriptor VertexLL; typedef graph_traits<GraphLL>::vertex_iterator vertex_iter; //Add an associative color map type. typedef map
color_map_t; color_map_t color_map; //Declare a container GraphLL g; //Graph and color_map should fit. //Fill graph g VertexLL v0 = boost::add_vertex(g); VertexLL v1 = boost::add_vertex(g); g[v0] = Int(0); g[v1] = Int(1); add_edge(v0, v1, g);
//Intitalize the colormap BGL_FORALL_VERTICES(v, g, GraphLL) { color_map[v] = white_color; } //Generate an assoc property map associative_property_map
pm_color(color_map); Visitor<GraphLL> vis; //Again compiler errors here: boost::depth_first_search(g, visitor(vis), pm_color); //(*)
You are mixing named parameters and positional parameters -- try either:
boost::depth_first_search(g, vis, pm_color);
or:
boost::depth_first_search(g, visitor(vis).color_map(pm_color));
and see if either of those work.
yes, this was it! Thanks for the answer. This is little trap one can fall into. When extending examples from the documentation using different overloads of an algorithm it is easy to overlook that parameter types are changing from 'named' to 'positional' mode... Thanks for helping :) Cheers, Joachim -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de