"Algorithm" shortest circuit-two points minimum total right and

Source: Internet
Author: User
Single Source shortest circuit problem

Solving the shortest path of a point to all other points use BFS to find the quickest way

"Algorithmic Competition Primer"
The sixth chapter of the data structure Basic diagram Part--zzyafyj column Dijkstra algorithm

"Sit on the toilet." Algorithm 7:dijkstra Shortest Path algorithm

We found dis[3]=12,dis[2]+e[2][3]=1+9=10,dis[3]>dis[2]+e[2][3], so dis[3] to be updated to 10. This process has a professional term called "slack". The distance from vertex 1th to number 3rd is dis[3], which is 2->3 by the edge of the strip. This is the main idea of the Dijkstra algorithm: "Edge" to relax the number 1th vertex to the rest of the vertices of the distance.

Each time you find the closest vertex to the source point (the source of the above example is vertex 1th), it is then scaled to the center of the vertex, resulting in the shortest path from the source point to all the remaining points. Shortest -circuit problem between any two points

Floyd-warshall algorithm for solving the shortest-circuit problem between all two points

Sit on the toilet look algorithm: Only five elements of the Floyd shortest path algorithm

At the beginning, only the 1th vertices are allowed to relay, then only the 1 and 2nd vertices are allowed to relay ... The shortest distance between any two points is allowed through all vertices of the 1~n number. In a nutshell: From the I vertex to the J vertex only passes the shortest distance from the front K points.

Reference article:
Challenge Program Design Competition
Sit on the toilet look algorithm: Only five elements of the Floyd shortest path algorithm
"Sit on the toilet." Algorithm 7:dijkstra Shortest Path 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.