# Algorithm research: Dijkstra algorithm of Shortest path

Source: Internet
Author: User

For a network diagram, the shortest path refers to the path of the sum of the edge weights passed between the vertices, and we call the first vertex on the path the source and the last vertex as the end point. The shortest path algorithms mainly include Dijkstra (Dijkstra) algorithm and Freud (Floyd) algorithm. First, the shortest path problem from one source point to the rest of the vertices is discussed.

This is a path by increasing the length of the order to generate the shortest path algorithm, its general idea is this.

For example, the shortest path to the vertex v0 to V1 in the graph 7-7-3 is obviously 1. Since vertex v1 is also connected to V2,V3,V4, at this time we have v0->v1->v2 = 1+3 = 4, V0->v1->v3 = 1 +7 = 8, v0->v1->v4 = 1+5 = 6.

Now we can see that the shortest distance from V0 to V2 is 4 instead of the V0->v2 Direct line of 5, as shown in Figure 7-7-4. Because vertex v2 also with V4,V5 line, so at the same time we got v0->v2->v4 is v0->v1->v2->v4 = 4+1=5,v0->v2->v5 = 4+7 = 11, here V0->v2 We're using the smaller 4 that we just calculated. At this point we also found that v0->v1->v2->v4 = 5 is smaller than v0->v1->v4 = 6, so the shortest distance v0 to V4 is now 5, as shown in Figure 7-7-5.

When we asked to V0 to the shortest path to V3, the three edges leading to the V3, except V6 not studied, V0->v1->v3 = 8, and v0->v4->v3 = 5 +2 = 7, so the shortest path v0 to V3 is 7, as shown in Figure 7-7-6.

As shown above, this algorithm is not a v0 to the shortest path to the V8, but a step-by-step to find the shortest distance between them, the process is based on the shortest path has been found on the basis of the shortest path to obtain more distant vertices, and finally get the desired results.

Related Keywords:

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.