Dijkstra Tool with directed graphs
Submitted by fausto on Wed, 01/18/2012 - 14:01
Hello:
I'm using the dijkstra tool in order to find the shortest path in a directed graph, however this tool seem to consider every edge to be bidirectional.
For instance, lets consider this simple example:
digraph
{
N1->N2;
N2->N3;
N3->N1;
}
After applying the algorithm I get that N3 is reachable with distance 1, having N1 as the previous node.
Is this supposed to happen? Any solution for this problem?
Thanks in advance. Best regards.
Recent comments
- I was able to resolve this
6 hours 14 min ago - x11 event bindings
1 day 23 hours ago - One could probable work
2 days 26 min ago - Would it be possible to
2 days 49 min ago - The simplest way is to set
2 days 52 min ago - Thanks, and self-learning for Graphviz
1 week 23 hours ago - There are various ways.
1 week 1 day ago - that did work
1 week 2 days ago - Hello,
You can also use
1 week 2 days ago - The boxes around clusters are
1 week 3 days ago

Dijkstra Tool
If the distance is 1 between each variable (N1N2, N2N3, N3N1) then yes, the tool is correct. If the distances between nodes varied (N1N2 = 2, N2N3 = 4, N3N1 = 7), then the shortest route from N1 to N3 would be to go through N2.
Dijkstra Tool
With the given lengths, the dijkstra tool correctly finds the shortest path from N1 to N3 goes through N2 and has length 6.
In the directed case, the shortest path has to go through N2.
Dijkstra Tool with directed
The dijkstra tool as of 27 January will accept a -d flag and then only follow forward edges.