《计算机网络课程设计报告》
if(l>i)................................................................................................................................................................18
{........................................................................................................................................................................18
printf("\n
从路由
%d
出发没有最短路径到其他端点
!\n",v0+1);..................................................................18
exit(0);..............................................................................................................................................................18
}//v0
是一个孤立的顶点
.................................................................................................................................18
D[v0]=0;..........................................................................................................................................................18
final[v0]=TRUE;..............................................................................................................................................18
for( j=0 ; j<i ; ++j ).........................................................................................................................................18
{........................................................................................................................................................................18
min=MaxNum;.................................................................................................................................................18
for( w=0 ; w<i ; w++).....................................................................................................................................18
{........................................................................................................................................................................18
if( !final[w] )//
判断是否已被最短路径路过
..................................................................................................18
{........................................................................................................................................................................18
if( D[w]<min )..................................................................................................................................................18
{........................................................................................................................................................................18
v=w;.................................................................................................................................................................18
min=D[w];.......................................................................................................................................................18
}//
找出最短的路径
..........................................................................................................................................18
}........................................................................................................................................................................18
}........................................................................................................................................................................18
final[v]=TRUE;................................................................................................................................................19
for( w=0 ; w<i ; w++ )....................................................................................................................................19
{........................................................................................................................................................................19
if( !final[w] && ( (min+a[v][w])<D[w]) ).....................................................................................................19
{........................................................................................................................................................................19
D[w]=min+a[v][w];........................................................................................................................................19
pre[w]=v;.........................................................................................................................................................19
}........................................................................................................................................................................19
}........................................................................................................................................................................19
}........................................................................................................................................................................19
}.........................................................................................................................................................................19
void Show(Status *D , Status *pre ,int i ,int v0)//D
是最短路径长度,
PRE
是最短路径经过的结点,
I
是