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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Containers;
package body Graph_Tests.Context is
function Neighbors_Check
return Test_Result
is
function Perm is new Is_Permutation (Node_ID, Positive, Graphs.Node_Array);
begin
if not Perm (My_Neigh_Graph.Neighbors (2), (1 => 3)) or
not Perm (My_Neigh_Graph.Neighbors (3), (2, 4)) or
not Perm (My_Complex_Graph.Neighbors (7), (5, 7)) or
not Perm (My_Nonempty_Graph.Neighbors (5), No_Nodes)
then
return Fail;
end if;
return Pass;
end Neighbors_Check;
function Parents_Check
return Test_Result
is
function Perm is new Is_Permutation (Node_ID, Positive, Graphs.Node_Array);
begin
if not Perm (My_Complex_Graph.Parents (9), (6, 7)) or
not Perm (My_Complex_Graph.Parents (7), (5, 7)) or
not Perm (My_Complex_Graph.Parents (1), No_Nodes)
then
return Fail;
end if;
return Pass;
end Parents_Check;
function Children_Check
return Test_Result
is
function Perm is new Is_Permutation (Node_ID, Positive, Graphs.Node_Array);
begin
if not Perm (My_Complex_Graph.Children (1), (5, 2)) or
not Perm (My_Complex_Graph.Children (2), (3, 4)) or
not Perm (My_Complex_Graph.Children (7), (5, 7, 9, 10)) or
not Perm (My_Complex_Graph.Children (10), No_Nodes)
then
return Fail;
end if;
return Pass;
end Children_Check;
function Outbound_Check
return Test_Result
is
function Perm is new Is_Permutation (Graphs.Edge_Type, Positive, Graphs.Edge_Array);
begin
if not Perm (My_Complex_Graph.Outbound (1), ((1, 1, 2), (5, 1, 5))) or
not Perm (My_Complex_Graph.Outbound (7),
((10, 7, 9), (11, 7, 10), (12, 7, 7), (13, 7, 5))) or
not Perm (My_Complex_Graph.Outbound (10), No_Edges)
then
return Fail;
end if;
return Pass;
end Outbound_Check;
function Inbound_Check
return Test_Result
is
function Perm is new Is_Permutation (Graphs.Edge_Type, Positive, Graphs.Edge_Array);
begin
if not Perm (My_Complex_Graph.Inbound (1), No_Edges) or
not Perm (My_Complex_Graph.Inbound (7), ((7, 5, 7), (12, 7, 7))) or
not Perm (My_Complex_Graph.Inbound (9), ((9, 6, 9), (10, 7, 9)))
then
return Fail;
end if;
return Pass;
end Inbound_Check;
function Between_Check
return Test_Result
is
function Perm is new Is_Permutation (Graphs.Edge_Type, Positive, Graphs.Edge_Array);
begin
if not Perm (My_Complex_Graph.Between (1, 10), No_Edges) or
not Perm (My_Complex_Graph.Between (2, 4), ((3, 2, 4), (4, 2, 4)))
then
return Fail;
end if;
return Pass;
end Between_Check;
function Outdegree_Check
return Test_Result
is
use type Ada.Containers.Count_Type;
begin
if My_Complex_Graph.Outdegree (1) /= 2 or
My_Complex_Graph.Outdegree (10) /= 0 or
My_Complex_Graph.Outdegree (2) /= 3
then
return Fail;
end if;
return Pass;
end Outdegree_Check;
function Indegree_Check
return Test_Result
is
use type Ada.Containers.Count_Type;
begin
if My_Complex_Graph.Indegree (1) /= 0 or
My_Complex_Graph.Indegree (7) /= 2 or
My_Complex_Graph.Indegree (2) /= 1
then
return Fail;
end if;
return Pass;
end Indegree_Check;
function Degree_Check
return Test_Result
is
use type Ada.Containers.Count_Type;
begin
if My_Complex_Graph.Degree (1) /= 2 or
My_Complex_Graph.Degree (10) /= 1 or
My_Complex_Graph.Degree (2) /= 4
then
return Fail;
end if;
return Pass;
end Degree_Check;
function Has_Edge_Check
return Test_Result is
begin
if not My_Complex_Graph.Has_Edge (1, 2) or
not My_Complex_Graph.Has_Edge (2, 4) or
My_Complex_Graph.Has_Edge (1, 10)
then
return Fail;
end if;
return Pass;
end Has_Edge_Check;
function Has_Neighbor_Check
return Test_Result is
begin
if not My_Neigh_Graph.Has_Neighbor (2, 3) or
not My_Neigh_Graph.Has_Neighbor (3, 2) or
My_Neigh_Graph.Has_Neighbor (2, 4) or
not My_Complex_Graph.Has_Neighbor (7, 7)
then
return Fail;
end if;
return Pass;
end Has_Neighbor_Check;
end Graph_Tests.Context;
|