#include<stdio.h>
#include<stdlib.h>
#define max 32767
int i, j, k, w,v,min;
struct map
{
int a[100][100];
};
void crate(map &m,int n,int e)
{
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
m.a[i][j] = max;
printf("i ,j ,w\n");
for (int k=1; k <= e; k++)
{
scanf_s("%d%d%d", &i, &j, &w);
m.a[i][j] = w;
}
printf("创建完成!\n
");
}
void dijiesite(map g, int n, int v1)
{
int
s[100],d[100], p[100];
for (v = 1; v <= n; v++)
{
d[v] = g.a[v1][v];
s[v] = 0;
if (d[v] < max)
{
p[v] = v1;
}
else
p[v] = 0;
}
d[v1] = 0, s[v1] = 1;
for (i = 1; i <= n; i++)
{
printf("%d", d[i]);
v = p[i];
printf("%5d", i);
while (v != 0)
{
printf("<-%d", v);
v = p[v];
}
printf("\n");
}
}
void main()
{
map m;
printf("输入顶点 边数\n");
int n, e;
scanf_s("%d%d", &n,&e);
crate(m, n,e);
printf("输入源点:");
scanf_s("%d", &v);
dijiesite(m, n, v);
system("pause");
}