On Monday 17 January 2005 10:31 pm, Tony Juricic wrote:
Has anybody created custom dijkstra_shortest_paths algorithm visitor for discover_vertex event?
We've used them quite often. Do you have a particular task in mind?
Reshuffling the code (but at this point I hardly know what am I really doing) I got the following to compile:
// define visitor for discover_vertex event
template
struct target_visitor : public default_dijkstra_visitor
{ target_visitor(Vertex u) : v(u) { }
template
void discover_vertex(Vertex u, Graph& g) { if ( u==v ) assert(0); } private: Vertex v; };
template
target_visitor target_visit(Vertex u, Tag) { return target_visitor (u); } ... // call dijkstra_shortest_paths with custom visitor // parameters below are defined as in dijkstra-example.cpp
dijkstra_shortest_paths(g, s, predecessor_map(&p[0]).distance_map(&d[0]).visitor(target_visit(D, on_discover_vertex())));
Looks good. You can actually omit the "Tag" template parameter (and all of the places it's passed along), because it won't be used. Just writing the discover_vertex function into the visitor is enough. Doug