I have a graph and want to do some shortest path searches with Dijkstra algorithm (I don't really care about the algorithm, but dijkstra is the one I am familiar with).
This is the relevant part of graph I have:
Now I do a dijkstra search following Quickgraph documentation:
//Build QuickGraph UndirectedGraph from our data
UndirectedGraph<int, Edge<int>> ug = g.CreateUndirectedQuickGraph();
Func<Edge<int>,double> weightFunc = (Edge<int> edge) =>
{
return 1; //without weights at this moment
};
var tryGetPath = ug.ShortestPathsDijkstra(weightFunc, 20);
IEnumerable<Edge<int>> path;
if (tryGetPath(23, out path))
foreach (var e in path)
Trace.WriteLine(e);
As you see, I'm trying to get the shortest path between node 20 and 23. And the output I get is
20 -> 4
22 -> 4
23 -> 22
It seems to be kind of right, but I don't really understand how to extract the node path from it. I expected something like:
20 -> 4
4 -> 22
22 -> 23
How can I build the final path from this output?
An example to get from 20 to 34:
20->3
5->3
8->5
9->8
36->9
36->11
34->11
Notice how 36->11
appears just before last edge.