private static List <Node> RetracePath(Node startNode, Node currentNode) { List <Node> path = new List <Node>(); do { path.Add(currentNode); currentNode = currentNode.parent; HandleAddToPath?.Invoke(currentNode); } while (currentNode != startNode); path.Reverse(); return(path); }
private static List <Node> RetracePath(Node startNode, Node currentNode) { List <Node> path = new List <Node>(); do { path.Add(currentNode); currentNode = currentNode.Parent; HandleAddToPath?.Invoke(currentNode); //visualization } while (currentNode != startNode); path.Add(startNode); return(path); }