summaryrefslogtreecommitdiff
path: root/test/graph_tests.ads
blob: c2dddfe28f948042473e7c2fa94a57439cd13f3a (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
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


with

    Ada.Strings.Unbounded,
    Directed_Graphs;


package Graph_Tests is


    package SU renames Ada.Strings.Unbounded;


    type Node_ID is new Positive;
    type Edge_ID is new Positive;
    type Node_Label is new SU.Unbounded_String;
    type Edge_Label is new SU.Unbounded_String;


    package Graphs is new Directed_Graphs
       (Node_ID_Type    => Node_ID,
        Edge_ID_Type    => Edge_ID,
        Node_Label_Type => Node_Label,
        Edge_Label_Type => Edge_Label);


    No_Nodes : Graphs.Node_Array (1 .. 0);
    No_Edges : Graphs.Edge_Array (1 .. 0);

    Dup_Nodes : constant Graphs.Node_Array := (1, 2, 2, 3, 5, 9, 9, 9);

    Some_Nodes : constant Graphs.Node_Array := (2, 5, 9, 11);
    Some_Edges : constant Graphs.Edge_Array := ((7, 2, 5), (2, 9, 11), (5, 11, 2));

    My_Empty_Graph : constant Graphs.Graph := Graphs.To_Graph (No_Nodes, No_Edges);
    My_Nonempty_Graph : constant Graphs.Graph := Graphs.To_Graph (Some_Nodes, Some_Edges);

    Complex_Nodes : constant Graphs.Node_Array := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    Complex_Edges : constant Graphs.Edge_Array :=
       ((1, 1, 2), (2, 2, 3), (3, 2, 4), (4, 2, 4),
        (5, 1, 5), (6, 5, 6), (7, 5, 7), (8, 6, 8), (9, 6, 9), (10, 7, 9), (11, 7, 10),
        (12, 7, 7), (13, 7, 5));

    My_Complex_Graph : constant Graphs.Graph := Graphs.To_Graph (Complex_Nodes, Complex_Edges);

    Neigh_Nodes : constant Graphs.Node_Array := (2, 3, 4, 5);
    Neigh_Edges : constant Graphs.Edge_Array :=
       ((1, 2, 3), (2, 3, 2), (3, 3, 4), (4, 4, 5), (5, 5, 4), (6, 4, 3));

    My_Neigh_Graph : Graphs.Graph := Graphs.To_Graph (Neigh_Nodes, Neigh_Edges);


private


    generic
        type Element_Type is private;
        type Index_Type is (<>);
        type Array_Type is array (Index_Type range <>) of Element_Type;
    function Is_Permutation
           (Left, Right : in Array_Type)
        return Boolean;


end Graph_Tests;