DIJKSTRA’S ALGORITHM
Aim
To implement Dijkstra’s algorithm
to find the shortest path.
Algorithm
Step1: [Include all the header
files]
Step2: Call allSelected( )
Step3: Call Shortpath( )
Step4: Access the functions from
main
Step5: End
Algorithm For ALLSELECTED( )
Step1: Initialise i=0
Step2: Check whether i<max
Step3: Check whether Selected[i]=0
Return 0
Step4: Else Return 1
Step5: Return
Algorithm For SHORTPATH( )
Step1: Initialise i=0 , Check i<max
Distance[i]=INFINITE
Step2: Assign
selected[current].distance[0]=0,
Current=0
Step3: While(!allSelected(Selected))
Perform(Selected[i]= =0)
Current=k
Selected[current]=1
Print k
Coding: