Dijkstra algorithm, Floyd algorithm and A * algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.