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;