Shortest path dijkstras algorithm, Data Structure & Algorithms

Assignment Help:

* Initialise d & pi*

for each vertex v within V( g )

g.d[v] := infinity

 g.pi[v] := nil

g.d[s] := 0;

* Set S to empty *

S := { 0 }

 Q := V(g)

* While (V-S) is not null*

while not Empty(Q)

1.   Sort the vertices within V-S according to the current best estimate of their distance from the source

 u := Extract-Min ( Q );

2.   Add vertex u, the closest vertex into V-S, to S, Add Node( S, u );

3.   Relax all of the vertices yet in V-S connected to u

relax( Node u, Node v, double w[][] )

if d[v] > d[u] + w[u]v] then

d[v] := d[u] + w[u][v]

pi[v] := u

 

In brief, this algorithm begins by assigning a weight of infinity to all of vertices, and then choosing a source & assigning a weight of zero to it. Vertices are added up to the set for which shortest paths are known. While a vertex is chosen, the weights of its adjacent vertices are relaxed. Once all of vertices are relaxed, their predecessor's vertices are updated (pi). The cycle of selection, weight relaxation & predecessor update is repeated till the shortest path to all vertices has been determined.


Related Discussions:- Shortest path dijkstras algorithm

How to write binary search algorithm?, Q. Write down the binary search algo...

Q. Write down the binary search algorithm and trace to search element 91 in following given list: 13          30          62           73         81         88             91

Kruskals algorithm, Krushkal's algorithm uses the concept of forest of tree...

Krushkal's algorithm uses the concept of forest of trees. At first the forest contains n single node trees (and no edges). At each of the step, we add on one (the cheapest one) edg

Write an algorithm to input number of passengers travelling, There are ten ...

There are ten stations on a railway line: Train travels in both directions (i.e. from 1 to 10 and then from 10 to 1).  Fare between each station is $2. A passenger input

Use of asymptotic notation in the study of algorithm, Q. What is the need o...

Q. What is the need of using asymptotic notation in the study of algorithm? Describe the commonly used asymptotic notations and also give their significance.

Data structure, Ask question #Minimum 1Mark each of the following statement...

Ask question #Minimum 1Mark each of the following statements as valid or invalid. If a statement is invalid, explain why. a. current ¼ list; b. temp->link->link ¼ NULL; c. trail->l

Spanning trees, Spanning Trees: A spanning tree of a graph, G, refer to a ...

Spanning Trees: A spanning tree of a graph, G, refer to a set of |V|-1 edges which connect all vertices of the graph. There are different representations of a graph. They are f

What is assertions and abstract data types, Assertions and Abstract Data Ty...

Assertions and Abstract Data Types Even though we have defined assertions in terms of programs, notion can be extended to abstract data types (which are mathematical entities).

A difference between linear and non linear, state difference between linear...

state difference between linear and non linear data structure. give one example scenario of each

The theta-notation, This notation bounds a function to in constant factors....

This notation bounds a function to in constant factors. We say f(n) = Θ(g(n)) if there presents positive constants n 0 , c 1 and c 2 such that to the right of n 0 the value of f

Data Structure, Ask consider the file name cars.text each line in the file ...

Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd