Hi everyone,
I posted this message but I haven't received any response so I decided
to post it again. 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 >. 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
void edge_relaxed(Edge e, Graph& g){
cout<<"VISITOR!!!"< "< 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.
a^2