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
- Can't compile gvmap on
20 hours 36 min ago - rendering bug
22 hours 11 min ago - rendering bug
22 hours 18 min ago - subnode
22 hours 21 min ago - cluster problem with manual
2 days 20 hours ago - Graphviz for Protege 4.0 with Lion? (Thanks, it's working)
1 week 1 day ago - can't cross-compile graphviz
1 week 1 day ago - SVG imagepath
1 week 1 day ago - Install graphviz via homebrew solves "dot -Tpng:gd" errors
1 week 1 day ago - force arrangement to side
1 week 2 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.