AStar algorithm (with the various structures used)