The A* algorithm implementation.