1

I am using the following code to compute the shortest paths length from source node s in G to all other nodes:

void class::initilize(int T, ListDigraph &G, ListDigraph::ArcMap <int> &duration,
                                  ListDigraph::ArcMap <int> &capacity, ListDigraph::NodeMap <int> &supply) {
vector<int> to_dist(countNodes(G));
vector<int> from_dist(countNodes(G));
Node s = getsource();
Node t = getsink();
//ListDigraph::NodeMap<int> dist(G);
lemon::Dijkstra<ListDigraph, Duration> dijkstra_instance(G, duration);
dijkstra_instance.run(s);
for (ListDigraph::NodeIt n(G); n != INVALID; ++n) {
    for (Node v=n;v != s; v=dijkstra_instance.predNode(v)) {
        std::cout << G.id(v) << "<-";
    }
    cout << dijkstra_instance.dist(n) << endl;
    cout << G.id(n) << endl;
    to_dist[G.id(n)] = dijkstra_instance.dist(n);
    dijkstra_instance.run(n, t);
    from_dist[G.id(n)] = dijkstra_instance.dist(t);
}

However, wenn I compare the computed paths length with the real ones, they are not true. Even the paths are wrong and a node with node id -1 appears in the output. When I now put dijkstra_instance.run(s) into the for-loop the computations are correct. Am I using the dijkstra command wrong?

Artem Zankovich
  • 2,319
  • 20
  • 36
Akay
  • 21
  • 8
  • can you show a code that reproduce the problem (maybe minimal graph instead of full graph?) it could be usefull for lemon developers to have a new test case to fix against. – CoffeDeveloper Oct 10 '15 at 08:02

0 Answers0