Inferensys

Glossary

A* Search

A* Search is a graph traversal and pathfinding algorithm that finds the shortest path between nodes by combining a cost-to-come function with a heuristic estimate of the cost-to-go.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
PATHFINDING ALGORITHM

What is A* Search?

A* (pronounced 'A-star') is a foundational graph traversal and pathfinding algorithm used extensively in AI planning, robotics, and game development to find the shortest path between nodes.

A search* is an informed search algorithm that finds the lowest-cost path from a start node to a goal node by combining the actual cost from the start, g(n), with a heuristic estimate of the cost to the goal, h(n). It prioritizes nodes with the lowest total estimated cost, f(n) = g(n) + h(n), using a priority queue. For the algorithm to be optimal (guarantee the shortest path), the heuristic must be admissible, meaning it never overestimates the true remaining cost.

The algorithm's efficiency stems from its best-first search strategy, which directs exploration toward the most promising goal. It is a cornerstone of corrective action planning for autonomous agents, enabling them to dynamically replan optimal execution sequences when errors are detected. Key variants include weighted A* for suboptimal but faster paths and D* for replanning in dynamic environments. Its computational complexity depends heavily on the heuristic's accuracy.

ALGORITHM FUNDAMENTALS

Key Properties of A* Search

A* search is defined by its core algorithmic components and formal guarantees. These properties determine its efficiency, optimality, and practical applicability in pathfinding and planning problems.

01

Admissibility & Optimality

The admissibility of the heuristic function h(n) is the cornerstone of A*'s optimality guarantee. An admissible heuristic never overestimates the true cost to reach the goal from any node n. This property ensures that when A* selects a goal node for expansion, the path cost g(n) is guaranteed to be the minimum possible. If h(n) is admissible, A* is optimally efficient, meaning no other optimal algorithm that uses the same heuristic expands fewer nodes. A common example is using straight-line Euclidean distance as h(n) for pathfinding on a grid; it's always less than or equal to the actual path distance around obstacles.

02

Consistency (Monotonicity)

A stronger property than admissibility is consistency (or monotonicity). A heuristic is consistent if for every node n and its successor n' generated by action a, the estimated cost satisfies the triangle inequality: h(n) ≤ cost(n, a, n') + h(n'). This implies that f(n) (the total estimated cost g(n) + h(n)) is non-decreasing along any path. The key practical implications are:

  • Consistent heuristics guarantee A* finds optimal paths without needing to re-open nodes in the closed set.
  • The algorithm's behavior is more predictable and efficient.
  • All consistent heuristics are admissible, but not all admissible heuristics are consistent.
03

The Evaluation Function f(n) = g(n) + h(n)

A*'s decision-making is driven by the evaluation function f(n) = g(n) + h(n), which estimates the total cost of the cheapest solution path passing through node n.

  • g(n) (Cost-to-Come): The exact, known cost from the start node to n. It represents the path already taken.
  • h(n) (Heuristic Cost-to-Go): An estimate of the cheapest cost from n to the goal. This is the "informed" part of the search that guides it toward the goal.
  • The algorithm always expands the node in the open set with the lowest f(n) value, balancing the certainty of the past (g(n)) with an informed estimate of the future (h(n)).
04

Completeness & Complexity

A* is complete on finite graphs with a positive edge cost function and a finite branching factor, meaning it will always find a solution if one exists. Its time and space complexity are a function of the heuristic's accuracy. In the worst case, where the heuristic provides no guidance (h(n) = 0), A* degenerates to uniform-cost search (Dijkstra's algorithm), with an exponential time and space complexity of O(b^d), where b is the branching factor and d is the solution depth. With a perfect heuristic (h(n) equals the exact cost-to-go), complexity reduces to O(d), as the search proceeds directly to the goal. In practice, a good heuristic dramatically prunes the search space.

05

Weighted A* & Suboptimal Variants

Standard A* finds an optimal path but can be slow in very large spaces. Weighted A (WA)** introduces a trade-off between optimality and speed by using the evaluation function f(n) = g(n) + w * h(n), where w > 1. This inflates the heuristic, making the search more greedy and goal-directed. While WA* does not guarantee optimality, it often finds a satisfactory solution much faster and provides an ε-optimal guarantee (solution cost ≤ ε * optimal cost, where ε = w). This is critical in real-time applications like video game AI or robotics, where a good path now is better than an optimal path too late.

06

Applications in Corrective Planning

Within Corrective Action Planning, A* is a foundational algorithm for an agent to compute an optimal sequence of corrective steps. The state space is defined by the agent's internal and external world model after an error is detected. Each action (e.g., "re-query API," "reformat data," "rollback transaction") has an associated cost (g(n)), often representing computational expense or risk. The heuristic h(n) estimates the remaining "effort" to reach a validated, correct state. By searching this space, the agent can find the minimal-cost recovery plan, embodying the principle of recursive error correction through optimal re-planning.

PATHFINDING ALGORITHM COMPARISON

A* Search vs. Other Search Algorithms

A comparison of key features and performance characteristics between A* search and other common search algorithms used in pathfinding and graph traversal for corrective action planning.

Algorithmic FeatureA* SearchDijkstra's AlgorithmGreedy Best-First SearchBreadth-First Search (BFS)

Optimality Guarantee

Heuristic-Driven

Time Complexity (Worst-Case)

O(b^d)

O((V+E) log V)

O(b^m)

O(b^d)

Space Complexity

O(b^d)

O(V)

O(b^m)

O(b^d)

Primary Use Case

Informed shortest-path search

Single-source shortest paths

Fast, non-optimal pathfinding

Uninformed graph traversal

Admissible Heuristic Required

Consistent Heuristic Required for Optimality

Exploration Strategy

Cost + heuristic (f(n)=g(n)+h(n))

Cost-to-come (g(n)) only

Heuristic (h(n)) only

Level-order (uninformed)

A* SEARCH

Frequently Asked Questions

A* search is a foundational algorithm in pathfinding and automated planning, crucial for agents that must formulate corrective action plans. These questions address its core mechanics, guarantees, and role in building self-correcting systems.

A search* is an informed graph traversal and pathfinding algorithm that finds the shortest path from a start node to a goal node. It works by evaluating nodes using a cost function f(n) = g(n) + h(n), where g(n) is the exact cost from the start node to node n, and h(n) is a heuristic estimate of the cost from n to the goal. The algorithm maintains a priority queue (the open set) of nodes to explore, always expanding the node with the lowest f(n) first. It terminates when the goal node is selected for expansion, guaranteeing an optimal path if the heuristic is admissible (never overestimates the true cost).

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.