[BGL] dijkstra visitor for examine edge event
Hi everyone, I am trying to store all the vertices with their respective distances from a source within the Dijkstra shortest path algorithm. For that I plan to use a std::vector<std::queue > >. I was able to have the visitor working but I don't know how to access to those values that are computed automatically by the algorithm (d_v, d_u, for example). The code I wrote is as follows: template <class Tag> struct vis : public default_dijkstra_visitor { vis() { } template <class Edge, class Graph> void edge_relaxed(Edge e, Graph& g){ cout<<"VISITOR!!!"<<endl; cout<<"Edge -> "<<e<<endl; } private: std::vector<std::queue<Vertex> > storage; }; template <class Tag> vis<Tag> target_visit(Tag) { return vis<Tag>(); } void Dijkstra() { // maps needed by the algorithm IndexMap indexmap = get(vertex_index, *gPtr); WeightMap weightmap = get(edge_weight, *gPtr); // define containers for the predecessor vertices and // for distances std::vector<Vertex> pred(num_vertices(*gPtr)); std::vector<double> dist(num_vertices(*gPtr)); // vertex to compute Dijkstra's algorithm on Vertex source = vertex(get_source(), *gPtr); // Dijkstra's algorithm dijkstra_shortest_paths(*gPtr, source, predecessor_map(&pred[0]).distance_map(&dist[0]).visitor(target_visit(on_examine_edge()))); ... Any help will be appreciated. aaragon
participants (1)
-
Alejandro Marcos Aragón