#include<stdio.h>
/*Total number of nodes*/
#define N 5
/*Defining an array for the address index of graph.dat*/
double add_index[N][2];
/*Adjacent list of the graph.dat file. An array of structure has been defined here. There will be structure for each node.
Each node will store the vertex number in the vertex of the structure, no of daughter vertices(known vertices) in the no_dvertex, and will have the vertex
number of the daughter vertices and the edge weights in the array d_info*/
struct node_info
{
unsigned int vertex;
unsigned int no_dvertex;
unsigned int d_info[7][2];
}node[N];
void dijkstra(unsigned int a, unsigned int b)
{
int i,j=1;
unsigned int weight;
weight=0;
unsigned int temp_weight;
unsigned int v_path[5];
unsigned int temp_vertex;
temp_vertex=a;
while(temp_vertex!=b)
{
temp_weight=node[temp_vertex].d_info[1][2];
for(i=2;i<=node[temp_vertex].no_dvertex;i++)
{
if(temp_weight>=node[temp_vertex].d_info[2])
{
temp_weight=node[temp_vertex].d_info[2];
temp_vertex=i;
}
}
weight=weight+temp_weight;
v_path[j]= temp_vertex;
j++;
}
}
void main()
{
struct node_info node[1]={1,2,{2,10},{4,5},{25,25},{25,25},{25,25},{25,25},{25,25}};
struct node_info node[2]={2,2,{3,1},{4,2},{25,25},{25,25},{25,25},{25,25},{25,25}};
struct node_info node[3]={3,1,{5,4},{25,25},{25,25},{25,25},{25,25},{25,25},{25,25}};
struct node_info node[4]={4,3,{2,3},{3,9},{5,2},{25,25},{25,25},{25,25},{25,25}};
struct node_info node[5]={5,2,{1,7},{3,6},{25,25},{25,25},{25,25},{25,25},{25,25}};
unsigned int a=1,b=2;
dijkstra(a,b);
}