Boost logo

Boost Users :

From: Tony Juricic (tonygeek_at_[hidden])
Date: 2005-01-17 22:31:18


Has anybody created custom dijkstra_shortest_paths algorithm visitor for
discover_vertex event?

I am having all sorts of compilation errors using MSVC 7.1 and defining
my visitor using example code.

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 <class Vertex, class Tag>
struct target_visitor
   : public default_dijkstra_visitor
{
   target_visitor(Vertex u) : v(u) { }

   template <class Vertex, class Graph>
   void discover_vertex(Vertex u, Graph& g)
   {
      if ( u==v )
     assert(0);
  }

private:
   Vertex v;
};

template <class Vertex, class Tag>
target_visitor<Vertex, Tag>
target_visit(Vertex u, Tag) {
   return target_visitor<Vertex, Tag>(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())));

Tony
Confused


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net