0

I'm trying to find an example of a directed graph with negative weights (no negative cycles) such that running dijksra on it will produce wrong results for all the vertices in the graph (except to the source node).

It isn't very hard to find an example to a graph where some of the results produced by dijkstra are wrong. but i can't find an example to a graph as described above, can anyone help me with it?

thanks.

  • 1
    The direct neighbors of the start vertex in the shortest path tree will always have correct distances. The worst you can get is a single correct vertex (plus start vertex). It is not possible to get no correct vertex. – Nico Schertler Sep 05 '16 at 00:30

1 Answers1

1

Suppose you have a graph G with three nodes A B and C. Three arcs (A,B,5) , (A,C,2) , (B,c,-10) and the source is A.

Now the shortest path from A to C will be 2 which is wrong.

It should be -5.