📄 emp7_13.cpp
字号:
procedure ShortPath(G:datagraph; V0:integer; var T:tree);
begin n:=nodes(g); setnull(Q);
for i:=1 to n do visited[i]:=false;
new(T); T^.data:=V0; T^.firstson:=nil; T^.nextBrother:=nil;
visited[V0]:=true; Enqueue(Q,t);
while not empty(Q) do
begin T1:=Outqueue(Q); V:=T^.data;
W:=firstadj(G,V); NumofSon:=0;
while W<>0 do
begin
if not visited[w] then
begin Numofsun:=Numofson+1;
new(T2); T^.data:=W;
T2^.firstson:=nil; T2^.nextBrother:=nil;
visited[W]:=true; Enqueue(Q,t2);
if NumofSon=1 then t1^.firstson:=t2
else t1^.nextbrother:=t2;
t1:=t2
end;
w:=nextadj(G,V,W)
end;
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -