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