Manhattan Distance
Manhattan distance also known as the MA Distance (Manhattan distance), but also seen more image, called Taxi distance. See Yellow Line, you should be able to understand.
The simplest way to calculate distances is the Manhattan distance. Assuming that the first two-dimensional case is considered, only two bands X and Y, User A is rated (X1,Y1), and User B is rated as (X2,y2), then the Manhattan distance between them is
A * Algorithm summary (Summary of the * method)
Ok, now that you have read the whole introduction, now we put all the steps together:
1. Add the starting point to the open list.
2. Repeat the following procedure:
A. Traverse the open list to find the node with the lowest F value, and use it as the node that is currently being processed.
B. Move the node to the close list.
C. For each square of the 8 adjacent squares of the current square?
If it is not reachable or it is in the close list, ignore it. Otherwise, do the following.
If it is not in the open list, add it to the open list and set the current square as its father, recording the square's F, G, and H values.
If it is already in the open list, it is better to check the path (that is, to reach it through the current square) and use the G value for reference. A smaller G-value indicates that this is a better path. If so, set its father to the current square and recalculate its G and F values. If your open list is sorted by the F value, you may need to reorder it after the change.
D. Stop, when you
The end is added to the open list, where the path has been found, or
The find endpoint failed, and the open list is empty and there is no path at this time.
3. Save the path. From the end point, each square moves along the parent node until it starts, and that's your path.
References:
http://blog.csdn.net/hitwhylz/article/details/23089415
A * Algorithm (introduction)