Advertisement
MadCortez

Untitled

Apr 23rd, 2021
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.63 KB | None | 0 0
  1. procedure DFS(Now: Integer; Path: TArr; Step: Integer; Child: Byte; LengthPath: Integer; Visited: TArr);
  2. var
  3.    Turn: Array[1..20] of Integer;
  4.    i, Size: Integer;
  5. begin
  6.    if Visited[Now] = 1 then
  7.    else
  8.    begin
  9.       Visited[Now] := 1;
  10.       Path[Step] := Now;
  11.       if Childs[Now] <> Child then
  12.          if MaxPath < LengthPath then
  13.          begin
  14.             MaxPath := LengthPath;
  15.             for i := 1 to LengthPath do
  16.                AnsArr[i] := Path[i];
  17.          end;
  18.       for i := 1 to 20 do
  19.          if Matrix[Now, i] = 1 then
  20.             DFS(i, Path, Step + 1, Child, LengthPath + 1, Visited);
  21.    end;
  22. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement