Visita DFS
ALGORITMO:
Procedure DFS (g:grafo);
var
u:integer;
begin
for u:=1 to maxnodi do
color[u]:='w';
for u:=1 to maxnodi do
if color[u]='w' then
DFSVISIT(u);
end;
Procedure DFSVISIT (u:integer);
var
v:integer;
paus:lista;
begin
color[u]:='g';
write (u,' ');
paus:=g[u];
while paus <> nil do
begin
v:=paus^.inf;
if color[v]='w' then
DFSVISIT(v);
paus:=paus^.next;
end;
end;
Torna a Programmazione e Lab.
Non ci sono commenti in questa pagina. [Scrivi commento]