A* search algorithm
For an example, we'll say A is connected to places B and C, and B and C are both connected to D and E. D and E are both connected to Z. There are 4 possible ways to go from A to Z. You can go A-B-D-Z, A-C-D-Z, A-B-E-Z, or A-C-E-Z. A computer using A* first looks at how hard it is to get from A to B, and from A to C. This is the "cost" for those places. The cost of a place means how hard it is to get from A to that place. After writing down both costs, the computer looks at how hard it is to get from B to D, and adds this to B's cost. It writes this down as D's cost. Then the computer looks at how hard it is to get from C to D, and adds this to C's cost. This is a different cost for D, and if it's less than the one it already has, it will replace the old one. The computer only wants to know the best path, so it ignores the path with the higher cost. It will only remember one of A-B-D and A-C-D, whichever is faster.