Inferensys

Glossary

A* Search

An informed graph traversal and pathfinding algorithm that uses a heuristic to estimate the cost to the goal, efficiently finding the shortest path by prioritizing nodes that appear to lead most quickly to the destination.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
INFORMED PATHFINDING

What is A* Search?

A* (pronounced 'A-star') is an informed graph traversal and pathfinding algorithm that finds the shortest path between a start and goal node by combining the actual cost to reach a node with a heuristic estimate of the cost to the goal.

A* search is a foundational algorithm in dynamic route optimization that evaluates nodes using a cost function f(n) = g(n) + h(n), where g(n) is the exact cost from the start to node n and h(n) is an admissible heuristic estimating the remaining cost to the goal. By prioritizing nodes with the lowest f(n) value, A* guarantees the shortest path while exploring far fewer nodes than uninformed algorithms like Dijkstra's Algorithm.

The algorithm's efficiency depends critically on the heuristic's admissibility and consistency. In logistics applications, common heuristics include straight-line distance or travel time under ideal conditions. A* serves as the core pathfinding engine within broader Vehicle Routing Problem solvers, where it rapidly computes optimal routes between waypoints before metaheuristics like Adaptive Large Neighborhood Search optimize the overall sequence.

INFORMED PATHFINDING

Key Characteristics of A* Search

A* search is a foundational informed graph traversal algorithm that combines the strengths of Dijkstra's algorithm and Greedy Best-First Search. By using a heuristic function to estimate the cost to the goal, it efficiently finds the shortest path while exploring far fewer nodes than uninformed methods.

01

The Core Evaluation Function

A* evaluates nodes using the formula f(n) = g(n) + h(n).

  • g(n): The exact cost of the path from the start node to the current node n.
  • h(n): A heuristic estimate of the cheapest cost from node n to the goal.
  • f(n): The estimated total cost of the cheapest solution passing through n.

The algorithm maintains a priority queue (open set) and always expands the node with the lowest f(n) value, guaranteeing optimality when the heuristic is admissible.

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

Admissibility and Optimality

A heuristic function h(n) is admissible if it never overestimates the true cost to reach the goal. This is the critical property that guarantees A* will find the optimal path.

  • Example: Straight-line distance is an admissible heuristic for road networks because the shortest path between two points can never be shorter than a direct line.
  • Consequence: If h(n) is admissible, A* is guaranteed to return the minimum-cost path.
  • Contrast: A non-admissible heuristic may find a path faster but can lead to suboptimal results.
Optimal
With Admissible Heuristic
03

Consistency (Monotonicity)

A heuristic is consistent (or monotonic) if, for every node n and every successor n' generated by an action a, the estimated cost of reaching the goal from n is no greater than the step cost of getting to n' plus the estimated cost from n'.

  • Rule: h(n) ≤ cost(n, a, n') + h(n')
  • Benefit: A consistent heuristic is also admissible. More importantly, consistency ensures that A* finds the optimal path to all expanded nodes, not just the goal, enabling more efficient graph search without re-opening closed nodes.
Graph Search
No Re-expansion Needed
04

Common Heuristics in Logistics

The choice of heuristic dramatically impacts A* performance. In logistics and routing, standard heuristics include:

  • Euclidean Distance: Straight-line distance; admissible for any physical space.
  • Manhattan Distance: Sum of absolute coordinate differences; admissible for grid-based networks with 4-directional movement, such as warehouse layouts.
  • Great-Circle Distance: The shortest path over the earth's surface; admissible for long-haul logistics and air freight routing.
  • Precomputed Landmarks: Using Contraction Hierarchies or ALT (A*, Landmarks, Triangle inequality) to create highly accurate, domain-specific heuristics for road networks.
ALT
Landmark-Based Heuristic
05

A* vs. Dijkstra's Algorithm

A* is a direct extension of Dijkstra's algorithm, which is a special case of A* where h(n) = 0 for all nodes.

  • Dijkstra's: Explores uniformly in all directions. Guarantees the shortest path but visits many irrelevant nodes. Equivalent to a breadth-first search weighted by cost.
  • A*: Focuses search toward the goal using the heuristic. Explores significantly fewer nodes while maintaining optimality.
  • Trade-off: In the worst case (a deceptive heuristic), A* can degrade to Dijkstra's performance, but in practice, it is orders of magnitude faster on large graphs like continental road networks.
h(n)=0
Dijkstra's as A* Special Case
06

Weighted A* for Dynamic Environments

In time-sensitive logistics applications like Dynamic Route Optimization, a variant called Weighted A* (WA*) is often used.

  • Formula: f(n) = g(n) + ε · h(n), where ε > 1.
  • Effect: The inflated heuristic makes the algorithm greedier, finding a solution much faster at the cost of bounded suboptimality.
  • Bounded Relaxation: The solution cost is guaranteed to be no more than ε times the optimal cost.
  • Use Case: Real-time re-routing where a near-optimal solution delivered in milliseconds is preferable to a perfect solution that takes seconds.
ε > 1
Suboptimality Bound
ALGORITHM COMPARISON

A* Search vs. Other Pathfinding Algorithms

A technical comparison of A* search against foundational pathfinding algorithms used in dynamic route optimization and logistics planning.

FeatureA* SearchDijkstra's AlgorithmGreedy Best-First

Heuristic Function

Required (admissible)

Required (any)

Optimality Guarantee

Completeness

Search Direction

Goal-directed

Uniform in all directions

Goal-directed

Worst-Case Time Complexity

O(b^d)

O((V+E) log V)

O(b^m)

Memory Usage

High (stores frontier)

High (stores all nodes)

Moderate

Re-Expands Nodes

Possible with inconsistent heuristic

Best Use Case

Known goal location with good heuristic

Unknown goal or all-pairs shortest path

Fast approximate pathfinding

ALGORITHM DEEP DIVE

Frequently Asked Questions

Explore the mechanics, applications, and limitations of the A* search algorithm, the foundational pathfinding engine behind modern dynamic route optimization and autonomous logistics.

The A* search algorithm is an informed graph traversal and pathfinding algorithm that finds the shortest path between a start node and a goal node. It works by maintaining a priority queue of nodes to explore, prioritized by a cost function f(n) = g(n) + h(n). g(n) is the exact cost of the path from the start node to the current node n. h(n) is a heuristic function that estimates the cheapest cost from n to the goal. By combining actual cost-to-date with estimated cost-to-go, A* balances the efficiency of a greedy best-first search with the optimality guarantee of Dijkstra's algorithm, expanding only the most promising nodes.

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.