double adj[V][V];
int spt[V];
int dijkstra(int s)
{
int v, w, min;
int in[V];
double wt[V + 1];
for (int i = 0; i < V;i++)
{
in[i] = 0;
wt[i] = MAX;
}
spt[s] = s;
wt[V] = MAX;
for (min = s;min != V;)
{
v = min;
in[min] = 1;
min = V;
for (w = 0;w < V;w++)
{
if (in[w])continue;
if (wt[w] > wt[v] + adj[v][w])
{
wt[w] = wt[v] + adj[v][w];
spt[w] = v;
}
if (wt[w] < wt[min])
min = w;
}
}
}