Here is my code using 4-point connectivity to find a shortest way between 2 points on a matrix. How should I change it if I want to use 8-point connectivity wavefront algorithm?