public DijkstraFindAllPathsResponse <TNode> FindAllPaths(TNode start) { InitSets(start); while (unexploredSet.Count > 0) { TNode current = unexploredSet.Pool(); double distanceFromNode = distanceFromStartToNode[current]; foreach (TNode neightboar in heuristicImpl.GetNeighboars(current)) { double distanceFromStart = distanceFromNode + heuristicImpl.VertexLength(current, neightboar); double distanceToN = distanceFromStartToNode.ContainsKey(neightboar) ? distanceFromStartToNode[neightboar]: double.MaxValue; if (distanceFromStart < distanceToN) { ReplaceInDictionary(distanceFromStartToNode, neightboar, distanceFromStart); ReplaceInDictionary(nodeToParent, neightboar, current); if (!unexploredSet.Contains(neightboar)) { unexploredSet.Add(neightboar, distanceFromStart); } } } } return(new DijkstraFindAllPathsResponse <TNode> { distances = distanceFromStartToNode, nodeToParent = nodeToParent }); }
private void AddWithPriotiry(TNode node, IComparable priority) { if (!notEvaluatedNodes.Contains(node)) { notEvaluatedNodes.Add(node, priority); } }