Exemple #1
0
        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);
        }
Exemple #2
0
 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;
 }