blob: 321313f5d8e2beefbf7e3d7ab1caa3abcc186bdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package body Graph_Tests is
function Is_Permutation
(Left, Right : in Array_Type)
return Boolean
is
Marked_Off : array (Right'Range) of Boolean := (others => False);
Same_Count : Natural := 0;
begin
if Left'Length = 0 and Right'Length = 0 then
return True;
end if;
if Left'Length /= Right'Length then
return False;
end if;
for L in Left'Range loop
for R in Right'Range loop
if Left (L) = Right (R) and not Marked_Off (R) then
Marked_Off (R) := True;
Same_Count := Same_Count + 1;
exit;
end if;
end loop;
end loop;
return Same_Count = Left'Length;
end Is_Permutation;
end Graph_Tests;
|