Search code examples
algorithmpath-finding

Total cost of the shortest path (A* algorithm)


What does the "Total cost of the shortest pathway" mean when we use A* algorithm to find the shortest pathway between two nodes. Is it the total of final cost (G + H) of all the nodes in the pathway or total of heuristic costs of all the nodes in the pathway or total of movement cost of each and every node in the pathway? It would be grateful if someone can help me to get a clear understanding because I have an upcoming test on Algorithm and data structures.


Solution

  • It is the cost of the shortest path, i.e. the sum of the costs of the edges that are in the shortest path (between 2 given nodes I guess). When A* reaches the end from the start you should have H=0 for this node, so it is also the value associated to the end node when you reach it...