JBSnorro
JBSnorro

Reputation: 6726

A* - Simple graph example - wrong result

I’ve implemented and used A* several times and thought I knew everything there was to know about A*…. Until I encountered this example:

A* directed graph example

The graph consists of 4 nodes and 6 directed weighted edges. The heuristic is denoted per node by H=…. The heuristic is clearly admissible, so I don't see any problems with that.

The problem is to find the route from start to goal with the minimal total cost. The correct solution is the route taking the edges with the costs 36 and 18.

My implementation of A* performs the following steps(omitting any operations related to the closed list):

So the implementation produces the wrong result. What in these steps shouldn’t have happened?

Upvotes: 1

Views: 1083

Answers (1)

Ted Hopp
Ted Hopp

Reputation: 234797

For a heuristic to be admissible, it must be bounded from above by the actual cost to the goal. Your heuristic is not admissible and that's why you're getting the wrong answer. See, for instance, the Wikipedia article on A*.

Upvotes: 4

Related Questions