Know the difference between A* and Dijkstra's algorithm (pp. 241-243)
Transcribed Image Text: Cost = AccumulativeCostTo(E.From) + E.Cost + Cost To (Target)
Utilizing a heuristic in this way, the modified costs direct the search toward
the target node instead of radiating outward equally in all directions. This
results in fewer edges needing to be examined, thereby speeding up the
search and is the primary difference between A* and Dijkstra's algorithm.
NOTE If you set the heuristic cost to zero in A", the resulting search behaves
exactly the same as Dijkstra's algorithm.
Let's take a peek at how A* operates on the problem graphs used in the
PathFinder program.
A* in Action
Screenshot 5.8 shows the result of A* operating on the simple source-target
example problem. As you can see, no extraneous edges have been consid-
ered, and the path leads directly to the target. The heuristic function used is
the straight-line distance between two nodes.
Time Claped for A Sanchis 5.96-005
Graph Search Algorithms
♫
Screenshot 5.8. Do not pass Go, do not collect £200.
Time laped for each
351 06
Screen shot 5.9
Screen shot 5.9 is just as impressive. Observe how few edges the A* algo-
rithm had to consider before finding the target. As a consequence of this,
the time taken to perform the search is considerably less than for any of the
other searches (even though an evil square root is required to calculate the
heuristic cost).
HJ
H210 E: 1220
TLFEBOOK
The Secret Life of Graphs | 243
NOTE A* is proven to be optimally efficient. In other words, no other search
algorithm will expand fewer nodes in the quest for the least cost path between
source and target.
Transcribed Image Text: Graph Search Algorithms
diagonal edges cost more to traverse than horizontal or vertical ones. With
this in mind you can see how the algorithm has searched a similar distance
in every direction before reaching the target.
Screenshot 5.7 shows Dijkstra's algorithm operating on the more com-
plex map.
H²
Time Espod for Dia's Search is 0.000274
Screenshot 5.7
The Secret Life of Graphs | 241
H210 1220
Like the BFS, Dijkstra's algorithm examines an awful lot of edges.
Wouldn't it be great if the algorithm could be given hints as it progresses to
nudge the search along in the correct direction? Well, luckily for us, this is
possible. Ladies and gentlemen, please put your hands together in a round
of applause and welcome A*!
242 Chapter 5
Dijkstra with a Twist: A*
Dijkstra's algorithm searches by minimizing the cost of the path so far. It
can be improved significantly by taking into account, when putting nodes
on the frontier, an estimate of the cost to the target from each node under
consideration. This estimate is usually referred to as a heuristic, and the
name given to the algorithm that uses this method of heuristically directed
search is A* (pronounced ay-star). And jolly good it is too!
If the heuristic used by the algorithm gives the lower bound on the
actual cost (underestimates the cost) from any node to the target, then A* is
guaranteed to give optimal paths. For graphs that contain spatial informa-
tion, such as navigation graphs, there are several heuristic functions you
can use, the most straightforward being the straight-line distance between
the nodes in question. This is sometimes referred to as the Euclidean
distance.
TLFEBOOK
Graph Search Algorithms
A* proceeds in an almost identical fashion to Dijkstra's search algo-
rithm. The only difference is in the calculation of the costs of the nodes on
the search frontier. The adjusted cost, F, to the node when positioned on the
priority queue (the search frontier), is calculated as:
F=G+H
(5.3)
where G is the cumulative cost to reach a node and H is the heuristic esti-
mate of the distance to the target. For an edge E that has just come off the
frontier and been added to the SPT, the pseudocode to calculate the cost to
its destination node looks like this:
Cost AccumulativeCostTo(E.From) + E.Cost + CostTo(Target)
Utilizing a heuristic in this way, the modified costs direct the search toward
Process or set of rules that allow for the solving of specific, well-defined computational problems through a specific series of commands. This topic is fundamental in computer science, especially with regard to artificial intelligence, databases, graphics, networking, operating systems, and security.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps