4 ms·
10 second explanation of A star: you have a graph + matrix of node-node distances. You want to find shortest path from origin to destination. Standard Dijsktra
by ramanujan 16y ago
10 second explanation of A star: you have a graph + matrix of node-node distances. You want to find shortest path from origin to destination. Standard Dijsktra only allows lookahead of one node at a time. A star allows you to incorporate a long range heuristic, like Euclidean distance from current node to destination. This gives a lower bound on current candidate path length and allows you to discard bad paths more rapidly.
Note that in all cases you need some basis for this heuristic (eg lat/lng of each node). Also, while 2D maps/nodes as cities is a great way to build your intuition for the algorithm, you can generalize it to arbitrary node types as long as heuristic function gives a good lower bound.