0% found this document useful (0 votes)
77 views

Dijkstra

The document describes the Dijkstra algorithm for finding the shortest paths between nodes in a graph. It works by marking the closest unmarked node, then updating the distances of all unmarked neighbors if going through the closest node would be shorter. This process repeats until all nodes are marked. The algorithm is presented pseudocode showing it initializes the source node distance to 0, then repeatedly selects the closest unmarked node and updates neighboring nodes' distances if a shorter path is found through the selected node.

Uploaded by

api-3696125
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Dijkstra

The document describes the Dijkstra algorithm for finding the shortest paths between nodes in a graph. It works by marking the closest unmarked node, then updating the distances of all unmarked neighbors if going through the closest node would be shorter. This process repeats until all nodes are marked. The algorithm is presented pseudocode showing it initializes the source node distance to 0, then repeatedly selects the closest unmarked node and updates neighboring nodes' distances if a shorter path is found through the selected node.

Uploaded by

api-3696125
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Dijkstra Algorithm

BY
Javed Siddique
Dijkstra Algorithm
• Void Dijkstra(Vertex s) {
– Vertex v, w;
– S.dist=0;
– For( ; ;){
• V = smallest unknown distance vertex
• V.known=true;
• For each w adjacent to v
– If ( !w.known)
» {
» If(v.dist + w_via_v < w.dist){
» Decrease (w.dist to v.dist + w_via_v )
» W.path= v
» }
» }
• }
– }
• }
}
MST Algorithm
• Void Dijkstra(Vertex s) {
– Vertex v, w;
– S.dist=0;
– For( ; ;){
• V = smallest unknown distance vertex
• V.known=true;
• For each w adjacent to v
– If ( !w.known)
» {
» If( w_via_v < w.dist){
» Decrease (w.dist tow_via_v )
» W.path= v
» }
» }
• }
– }
• }
}

You might also like