If you are looking for a specific vertex and conclude when you find it, I would recommend using A * , which is the best -first search.
The idea is that you calculate the distance from the original vertex to the current vertex that you are processing, and then โguessโ the distance from the current vertex to the target.
You start from the source, calculate the distance (0) plus fortune telling (no matter what it may be) and add it to the priority queue, where the priority is the distance + guess. At each step, you delete the element with the smallest distance + guess if you are performing calculations for each vertex in the adjacency list and inserting them into the priority queue. Stop when you find the target peak.
If your heuristic (your โhunchโ) is acceptable, that is, if it is always underestimated, you are guaranteed to find the shortest path to your target peak on your first visit. If your heuristic is unacceptable, you will need to run the algorithm before completion to find the shortest path (although it sounds like you don't need the shortest path, just any path).
No more difficult to implement than a breadth-first search (you just need to add a heuristic, really), but this will probably give faster results. The only hard part is figuring out your heuristic. For peaks that represent geographic locations, a common heuristic is to use crow-fly-heuristics (forward distance).
source share