public static (string[] path, int distance) Dijkstra(ISearchableGraph graph, string from, string to) { var startNode = new DijkstraNode(graph, from, 0, to); var result = Search <HeapPriorityQueue <SearchNode> > .Execute(startNode); var path = result.GetPath().Select(sn => { var gsn = sn as DijkstraNode; return(gsn.graphNode); }).ToArray(); return(path, result.cost); }
public DijkstraNode(ISearchableGraph graph, string graphNode, int cost, string targetNode, DijkstraNode parent = null) : base(cost, parent) { this.graph = graph; this.graphNode = graphNode; this.targetNode = targetNode; }