I am trying to implement the shortest path algorithm for a program of mine. But unfortunately I am not allowed to use queue and only an in built bool value that marks the AD