code:
void spfa()
{
int h=1,t=1,i,j,k;
d[1]=1;
dis[1]=0;
bz[1]=true;
while (h<=t)
{
int l=d[h];
i=g[l];//前向新
while (a[i][0]==l)
{
int x=a[i][1];
if (a[i][2]+dis[l]<dis[x])
{
dis[x]=a[i][2]+dis[l];
if (bz[x]==false)
{
bz[x]=true;
t++;
d[t]=x;
}
}
i++;
}
bz[l]=false;
h++;
}
}