Shortest path algorithm (Dijkstra algorithm, Floyd-warshall algorithm)

Source: Internet
Author: User

The shortest path algorithm includes:

Determine the Shortest Path of the start point: Find the shortest path when the Start Node is known.Suitable for useDijkstra Algorithm.

The shortest path for determining the end point: the problem of finding the shortest path when the end point is known. In an undirected graph, this problem is equivalent to the problem of determining the starting point. In a directed graph, this problem is equivalent to the problem of determining the starting point when all paths are reversed.

Determine the Shortest Path of the start and end points: Find the shortest path between the two nodes.

Global shortest path problem: Find all shortest paths in the graph. Floyd-warshall algorithm.

 

Dijkstra algorithm idea: At the beginning, S = {u}, t = V-{u}; for all vertices x in T, if u to X has an edge, set d (u, x) = C (u, x); otherwise d (u, x) = infinity. Loop: Find the smallest vertex t of d (u, x) for all vertices x in T, that is, d (u, t) = min {d (u, X) | X belongs to t}, then d (u, T) is the Shortest Path Distance from vertex t to vertex u. In addition, vertex T is the closest vertex of all vertices in set t to U. Delete vertex t from T and merge it into S. Then, for all vertices x adjacent to T in T, use the following formula to update the value of d (u, X): d (u, x) = min {d (u, x), d (u, t) + C (t, x )}. Continue "loop" until T is null. The concept of the Floyd-warshall algorithm is similar to that of the Dijkstra algorithm: it finds the end-to-end shortest path by bypassing the intermediate node and does not describe it.

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.