public Distances PathToGoal(Cell goal) { var current = goal; var breadcrumbs = new Distances(root); breadcrumbs[current] = cells[current]; do { foreach (Cell neighbor in current.Links) { if (cells[neighbor] < cells[current]) { breadcrumbs[neighbor] = cells[neighbor]; current = neighbor; break; } } } while(current != root); return(breadcrumbs); }
public Distances PathToGoal(Cell goal) { var current = goal; var breadcrumbs = new Distances(root); breadcrumbs[current] = cells[current]; do { foreach (Cell neighbor in current.Links) { if (cells[neighbor] < cells[current]) { breadcrumbs[neighbor] = cells[neighbor]; current = neighbor; break; } } } while(current != root); return breadcrumbs; }