liveBook · Manning

A-star algorithm

As explained in Clojure: The Essential Reference

A* is a graph-search algorithm that selects paths using the sum of accumulated path cost and a heuristic estimate of remaining cost.

A* searches for a shortest path through a graph by prioritizing each candidate with accumulated path cost plus a heuristic estimate of remaining cost. A priority queue, represented here by a sorted map, keeps promising paths first. section 11.1.3

Finding a route

(a* graph :orig :dest) ;; [:orig :d :e :dest] The sample graph assigns straight-line-like estimates to guide navigation; changing the origin and destination produces another route.

How Clojure: The Essential Reference covers it

How deep it goes
Explains graph representation, heuristic scoring, queue ordering, neighbor discovery, recursion, and sample routes.
Examples
Uses a cyclic location graph, composite sorted-map keys, and routes from :orig to :dest and from :d to :c.
What it assumes
Assumes graph nodes, edge costs, priority queues, sorted maps, and heuristic distance estimates.
What you can do after
Builds a small A* pathfinder in Clojure using sorted-map-by as its priority queue.
How it connects
Connects A* with priority queues, graph search, heuristics, sorted maps, and comparators.

Also explained in

Compare how 5 books explain A-star algorithm →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.