DIJKSTRA SHORTEST PATH ALGORITHM:

 links:

                                        Hobbies:

                                           Sketches The Girl...

                                       Small Unwonderful Story


 Programming Languages:

                                 C++

                              JAVA

                              HTML


  

  Something:

         Sybsc computer science: sem 4, Questions paper

         some c programs

          file handling in c

  File Handling simple concept & programs

  microcontroller programs (electronics)

  Raspberry pi & Arduino programs

Data Structure in c: 

             Linear data structure

                    SEARCHING AND SORTING

                    Link List Opearations

                    STACK & QUEUE


NON-linear Data Structure:

-  BINARY SEARCH TREE

 Implement Graph as Adjacency matrix and Adjacency list

-  BINARY SEARCH TREE ASSIGNMENT 1 

-  BINARY SEARCH TREE ASSIGNMENT 2

-  HASH TABLE    

-  GRAPH TRAVERSAL : BFS & DFS

-  INDEGREE OUTDEGREE & TOTAL DEGREE OF VERTEX IN GRAPH

 Graph-Adjacency list

-  DIJKSTRA SHORTEST PATH ALGORITHM:


 


DIJKSTRA SHORTEST PATH ALGORITHM:


//Dijkstra's Shortest Path
#include<stdio.h>
int cost[4][4]={{0, 5 ,999, 20},
                {999,0,10,999},
                {4,999,0,8},
                {999,7,999,0}            
               };

 void dijkstra(int v,int n)
 {
     int i,j,u,w,min,count;
     int dist[10],visited[10]={0};
     visited[v]=1;
      for(i=0;i<n;i++)
        dist[i]=cost[v][i];
      count=2;
      while(count<n)
       {
         min=999;
         for(i=0;i<n;i++)
           if(visited[i]==0 && dist[i]<min)
            {
             min=dist[i];
             u=i;
            }
         visited[u]=1;
         for(w=0;w<n;w++)
           if(dist[u]+cost[u][w]<dist[w])
             dist[w]=dist[u]+cost[u][w];
         count++;
     }
         printf("\nShortest distances from the vertex %d are:\n",v);
          for(i=0;i<n;i++)
            printf("%d\t",dist[i]);
         }
     
 
 void main()
 {
     dijkstra(0,4);
 }


S

Comments

Popular posts from this blog

Practical slips programs : Machine Learning

Full Stack Developement Practical Slips Programs

Android App Developement Practicals Programs