Looking at the image above, thinking in terms of A* search. I don't fully understand the heuristic function. The cost makes sense, so thinking in terms of a traditional map or navigation scenario. I'd see the heuristic function here as the number of direct steps. Or the number of cities we pass through, for example. The cost then is the number of miles between each city.
Am I right in thinking that it's the number of direct paths before we reach a path where there are multiple choices?
What confused me is, that I've also seen other examples where these numbers don't add up. For instance the image below:
The numbers in the second image don't add up the number of nodes on any path. Is it a case that the heuristic function varies from problem to problem, and I shouldn't think about how those numbers were generated too much? And that heuristic functions themselves are a separate problem, that we're just taking for granted in these two images?