Snake and ladder graphs

my code link
i cant identify the mistake please help
i even made a -1 case and it works fine
u can try uncommenting the path i am printing