The thing with the A * algorithm is that it is complete and optimal. This means that he will find the path to the solution if there is a path, but also ensures that he first finds the shortest path.
This is due to the fact that the heuristic function A * must be a valid heuristic ; that is, he should not overestimate the distance to the target.
This, in turn, ensures that as soon as you find a path to a solution, you know that in the rest of the search space there are no paths smaller than this.
Let's say that the distance to your first solution was d (problem). Now my last statement actually means that if you keep going only after you find the first solution d (problem) and find another solution, d2 (problem) there are two possibilities:
- d2 () = d (): , . , d2 = d
- d2 () > d (): , , : d2. , d2 , . , d2
- , , d2 () d (), , .
, : , , , . , ( ) , .
" " . , , - . . , : , 0 inf. , [0, 1). , a > b , , a == b , .
, , , . , . , .
, , ( , ). , , , , , , .