A* Algorithm
Show pathfinding using cost, heuristic, and total estimated distance.
A* Evaluation Table
| Node | Cost g(n) | Heuristic h(n) | Total f(n) | Previous | Visited |
|---|---|---|---|---|---|
| AStart | 0 | 0 | 0 | - | 0 |
| B | ∞ | 0 | ∞ | - | 0 |
| C | ∞ | 0 | ∞ | - | 0 |
| D | ∞ | 0 | ∞ | - | 0 |
| E | ∞ | 0 | ∞ | - | 0 |
About This Simulation
This A* search simulator shows how the algorithm finds a shortest path by combining the cost so far, g(n), with a heuristic estimate of the remaining distance, h(n). You can see the open and closed lists and the f, g and h values of every node.
Features
- Build a graph with edge costs and heuristic values
- Open list (frontier) and closed list shown at every step
- g(n), h(n) and f(n) = g(n) + h(n) for each node
- Node expansion order and the final path highlighted
- Step-by-step playback and fullscreen mode
Explanation
A* is an informed search algorithm that always expands the node with the smallest f(n) = g(n) + h(n), where g(n) is the cost from the start to n and h(n) is an estimate of the cost from n to the goal. With a good heuristic it reaches the goal while exploring far fewer nodes than Dijkstra.
How it works
- Put the start node in the open list with g = 0 and f = h(start).
- Remove the node with the smallest f value from the open list. If it is the goal, stop and trace the path back through the parent links.
- Move the node to the closed list.
- For each neighbour, compute g = g(current) + edge cost. If this is better than any g found before, update its parent, g and f = g + h, and add it to the open list.
- Repeat until the goal is reached or the open list is empty (no path).
Why it matters
A* is the standard pathfinding algorithm in games, robotics and map navigation. It appears in artificial intelligence courses (CSE440, CSE420, CSE427) and connects graph algorithms from CSE221 with heuristic search.
Frequently Asked Questions
What is f(n) = g(n) + h(n) in A*?
g(n) is the actual cost of the path from the start to node n, h(n) is the heuristic estimate of the cost from n to the goal, and f(n) is the estimated total cost of the cheapest path through n.
What is an admissible heuristic?
A heuristic is admissible if it never overestimates the true cost to reach the goal: h(n) ≤ actual cost from n to the goal for every node. With an admissible heuristic, A* tree search is guaranteed to find an optimal path.
What is a consistent (monotone) heuristic?
A heuristic is consistent if h(n) ≤ cost(n, m) + h(m) for every edge from n to m. Consistency implies admissibility and guarantees that A* graph search never needs to reopen a closed node.
How is A* different from Dijkstra's algorithm?
Dijkstra expands nodes by g(n) only, so it searches in every direction. A* adds the heuristic h(n) to steer the search toward the goal. Dijkstra is the same as A* with h(n) = 0.
Topics covered
- A* Search
- Informed (Heuristic) Search
- Admissible Heuristics
- Consistent Heuristics
- Shortest Path
- Pathfinding
Tags
- a star
- a*
- heuristic
- informed search
Related Simulations
Algorithms
Searching Algorithms
Run linear, binary, ternary and quaternary search on your own array and step through the code one line at a time.
Algorithms
Sorting Algorithm Visualiser
Visualise sorting algorithms
Algorithms
BFS (Breadth First Search) Simulator
Build interactive graphs and watch BFS explore networks level-by-level using a visual queue.
Algorithms
DFS (Depth First Search) Simulator
Build interactive graphs and watch DFS plunge down deep paths and backtrack using a visual stack.

