Leaving a trail of backpointers

Inside the core algorithm, we now need to keep a record of which path entering each cell in the grid was the best one.