Snakes and ladder BFS-SSSP problem

here our shortest path can be 0-15-29-33-36------------why the shortest path is only 0-15-29-30-36—

also why we have added the code line g.addEdge(36,36) specially to add the edge from the node 36 to 36------if we write g.addEdge(35,36) then the node 36 should have been created ------

  1. Ya you are right, it is because there can be multiple ways to reach the destination by shortest path, but the distance is same for all those paths.

2)No, when you do addEdge(35,36) then the 36 is added in the adjacency list of 35 but node 36 is not created, thats why we are manually doing it.