Line maze solver/w shortest path algorithm

please refer to this website

I got the algorithm from here and I am not able to complete it...
I have fixed some parts of the code please review it
I am having trouble with the cancellation part