首页 > 试题广场 >

下面为Dijkstra算法,请填入适当信息,完善该算法。

[填空题]
下面为Dijkstra算法,请填入适当信息,完善该算法。
PROC shortpath(cost,n,vo,dist,path);
FOR i:=1 to n DO
{
    dist[i]:=∞;path[i]:=[vo] };
    dist[v0]:=0;s:=[v0];j:= v 0 ;
    FOR K:=1 to n-1 DO
    {
        FOR K:=1 to 1 DO
            if not (i in S) and (2+cost[j,i]<dist[i])
            then{
                dist[i]:=dist[j]+cost{j,i];
                path[i]:=3
            };
        min:=∞;j:=v 0;
        FOR I:=1 TO n DO
        if NOT 4 and (dist[i]<min)
        then{j:=i;min:=dist[i]};
        s:=5;
    }
ENDP;

这道题你会答吗?花几分钟告诉大家答案吧!