A* 1. Set all distances to infinity, except the start node, which is set to 0
2. Add heuristic values to the table
3. Set start node as current node.
4. Add current node to the “open” list
5. Visit neighbours of this node, if distance from start is less than what is
currently in the table, update their distances from start, f distance and previous
node.
a. Note that f distance only includes the single heuristic distance of the single node
you are calculating for, but all the distances from start up to that node.
6. Add any neighbours not yet visited until now, into the open list – a priority
queue
7. Add current node to closed list, remove it from the open list
8. Set the node with the shortest f distance in the Open list as the current node
9. Repeat from step 4 until end node has been added to the closed list.
Node Distance from Heuristic F distance Previous node
start distance (g+h)
A 0 9
B ∞ 4
C ∞ 56 3 59 A
D ∞ 0
Dijkstra 1. Set all distances to infinity, except the start node, which is set to 0
2. Set start node as current node.
3. Add current node to the “open” list
4. Visit neighbours of this node, if distance from start is less than what is
currently in the table, update their distances from start and previous node.
5. Add any neighbours not yet visited until now, into Open – a priority queue
6. Add current node to closed list, remove it from the open list
7. Set the node with the shortest distance in the Open list as the current node
8. Repeat from step 3 until every node has been visited, and so the shortest path has
been found.
Node Distance from start Previous node
A 0
B ∞
C ∞ 56 A
D ∞
2. Add heuristic values to the table
3. Set start node as current node.
4. Add current node to the “open” list
5. Visit neighbours of this node, if distance from start is less than what is
currently in the table, update their distances from start, f distance and previous
node.
a. Note that f distance only includes the single heuristic distance of the single node
you are calculating for, but all the distances from start up to that node.
6. Add any neighbours not yet visited until now, into the open list – a priority
queue
7. Add current node to closed list, remove it from the open list
8. Set the node with the shortest f distance in the Open list as the current node
9. Repeat from step 4 until end node has been added to the closed list.
Node Distance from Heuristic F distance Previous node
start distance (g+h)
A 0 9
B ∞ 4
C ∞ 56 3 59 A
D ∞ 0
Dijkstra 1. Set all distances to infinity, except the start node, which is set to 0
2. Set start node as current node.
3. Add current node to the “open” list
4. Visit neighbours of this node, if distance from start is less than what is
currently in the table, update their distances from start and previous node.
5. Add any neighbours not yet visited until now, into Open – a priority queue
6. Add current node to closed list, remove it from the open list
7. Set the node with the shortest distance in the Open list as the current node
8. Repeat from step 3 until every node has been visited, and so the shortest path has
been found.
Node Distance from start Previous node
A 0
B ∞
C ∞ 56 A
D ∞