cpp
#include<stdio.h>
#define MAX 100
typedef struct Mgraph{
char vertex[MAX];
int arcs[MAX][MAX];
int vexnum,arcnum;
}Mgraph;
int Locate(Mgraph G,char v)
{
int i;
for(i=0;i<G.vexnum;i++){
if(G.vertex[i]==v){
return i;
}
}
return -1;
}
void Dijkstra(Mgraph G,char v,int n)
{
int D[MAX],path[MAX],T[MAX];
int i,j,m,k,min=9999;
k = Locate(G,v);
if(k==-1)
return;
for(i=0;i<G.vexnum;i++){
D[i] = G.arcs[k][i];
T[i] = 0;
if(D[i]<min){
path[i] = k;
}
else
path[i] = 0;
}
T[k] = i;
for(m=1;m<G.vexnum;i++){
min = 9999;
j = -1;
for(i=0;i<G.vexnum;i++){
if(T[i]==0&&D[i]<min){
j = i;
min = D[i];
}
}
if(j==-1)
break;
else{
T[j] = 1;
for(i=0;i<G.vexnum;i++){
if(T[i]==0&&D[j]+G.arcs[j][i]<D[i]){
D[i] = D[j] + G.arcs[j][i];
path[i] = j;
}
}
}
}
}
int main()
{
return 0;
}