A possible solution is to simulate your chart as AdjacencyGraph<string, Edge<string>> and build a dictionary of values Dictionary<Edge<string>, double> , where the costs are your distances.
// ... private AdjacencyGraph<string, Edge<string>> _graph; private Dictionary<Edge<string>, double> _costs; public void SetUpEdgesAndCosts() { _graph = new AdjacencyGraph<string, Edge<string>>(); _costs = new Dictionary<Edge<string>, double>(); AddEdgeWithCosts("A", "D", 4.0); // snip AddEdgeWithCosts("C", "B", 1.0); } private void AddEdgeWithCosts(string source, string target, double cost) { var edge = new Edge<string>(source, target); _graph.AddVerticesAndEdge(edge); _costs.Add(edge, cost); }
Now your _graph :

Then you can find the shortest path from A to E using:
private void PrintShortestPath(string @from, string to) { var edgeCost = AlgorithmExtensions.GetIndexer(_costs); var tryGetPath = _graph.ShortestPathsDijkstra(edgeCost, @from); IEnumerable<Edge<string>> path; if (tryGetPath(to, out path)) { PrintPath(@from, to, path); } else { Console.WriteLine("No path found from {0} to {1}."); } }
This is adapted from the QuickGraph wiki . He prints:
Path found from A to E: A > D > B > E
source share