some one can explain me how Dijkstra algorithm works?
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
The Djikstra algorithm finds the shortest path from one node to all the others producing a shortest path tree.
1. You start from a random node (node A in Your picture). Node A has a value of 0 because it's the starting node.
2. The path from A -> B = 2 so You assign the value 2 to node B.
3. The path from A - > G = 6 so You assign the value 6 to Node G. Since node A has no more neighbor nodes (there are no more nodes directly connected to node A) You are done with it. Your next node is the node with the smallest value (which is B with a value of 2).
4. Here we have B -> C = 7 so node C gets 7 + the value of B which is 2. So C = 9. B - > E = 2. So E gets the value 2 + 2 = 4. That's it for node B. The next one is E which has the smallest value (4).
5. The connections with E are E->F = 2 (F gets a 4 + 2) and E->G = 5. Now here is the important bit; G already has a value (it's 6). But since 5 < 6, we delete the value 6 and instead write the five. Thats because the path A->B->E->G = 5 is smaller than A -> G = 6. So G gets a new value: 5.
This process is repeated for every node. Here is a animation that could help You visualize the algorithm: http://upload.wikimedia.org/wikipedia/commons/4/45/Dijksta_Anim.gif