Dijkstra algorithm
The Dijkstra (Dijkstra) algorithm is a typical single-source shortest path algorithm that calculates the shortest path of a node to all other nodes. The main feature is to extend from the center of the starting point to the outer layer until it expands to the end point.
Floyd algorithm
The Floyd algorithm is a classical dynamic programming algorithm. In plain language, the first goal is to find the shortest path from point I to J. From the point of view of dynamic planning, we need to make a reinterpretation of this goal (this interpretation is the essence of dynamic planning the most creative)
The shortest path from any node I to any node J is 2 possible, and 1 is straight from I to j,2 from I through several nodes K to J. Therefore, we assume that dis (i,j) is the distance from the shortest path of node u to node V, for each node K, we check whether dis (i,k) + dis (k,j) < dis (I,J) is established, if it is established, prove that the path from I to K to J is shorter than I direct to J Path, We set up dis (i,j) = Dis (i,k) + dis (k,j) so that when we traverse through all nodes K,dis (i,j) The distance from the shortest path of I to J is recorded.
A * algorithm
Path scoring
The key to choosing which squares to go through in the path is the following equation:
F = G + H
Over here:
* G = move from Start a, along the resulting path, to the specified squares on the grid. The upper and lower left and right walk is 10, diagonal diagonal Walk is 14, the basic proportion.
* H = estimated movement cost of moving from that square on the grid to end B. h values can be estimated in different ways. The method we use here is called the Manhattan method, which calculates the sum of the horizontal and vertical squares from the current grid to the destination, ignoring the diagonal direction.
F is printed in the upper left corner, G in the lower left corner, and h in the lower right corner.
Dijkstra algorithm, Floyd algorithm and A * algorithm