agpl_1.0.0_b5da3320/src/agpl-containers-graphs.ads

  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
with Ada.Containers.Indefinite_Vectors,
     Ada.Containers.Indefinite_Ordered_Maps,
     Ada.Containers.Indefinite_Ordered_Sets,
     Agpl.Generic_Handle;

generic
   type Vertex_Type is private;
   No_Vertex : Vertex_Type;
   type Edge_Type   is private;
   No_Edge   : Edge_Type; -- Used to signal infinite length or missing
   with function "<" (L, R : Vertex_Type) return Boolean is <>;
   with function Image (V : Vertex_Type) return String is <>;
   with function "<" (L, R : Edge_Type) return Boolean is <>;
   with function Image (E : Edge_Type) return String is <>;
   --  Weight or something, must be true for all E < No_Edge
package Agpl.Containers.Graphs is

   pragma Preelaborate;

   type Graph is abstract tagged private;

   --  type Edge_Precursor is abstract tagged null record;
   --  Used only to have edge vectors of this class.
   --  Real instances will always be at least in Edge_Cursor'Class

   type Edge_Cursor is abstract tagged null record;

   type Vertex_Cursor is abstract tagged null record;

   --  GRAPH PRIMITIVES

   function Vertex_Count (This : Graph) return Natural is abstract;

   function Edge_Count (This : Graph) return Natural is abstract;

   function First (This : Graph) return Vertex_Cursor'Class is abstract;

   procedure Insert (This   : in out Graph;
                     Pos    :        Vertex_Cursor'Class;
                     Vertex :        Vertex_Type) is abstract;

   procedure Insert (This     : in out Graph;
                     Ini,
                     Fin      : Vertex_Cursor'Class;
                     Edge     : Edge_Type;
                     Directed : Boolean := False) is abstract;

   function Copy (This : Graph) return Graph is abstract;
   --  Copy creator

   procedure Clear (This : in out Graph) is abstract;


   --  VERTEX PRIMITIVES

   function Element (This : Vertex_Cursor) return Vertex_Type is abstract;

   function Next (This : Vertex_Cursor) return Vertex_Cursor is abstract;

   function Has_Element (This : Vertex_Cursor) return Boolean is abstract;

   --  EDGE PRIMITIVES

   function Element (This : Edge_Cursor) return Edge_Type is abstract;

   function First (This : Edge_Cursor) return Vertex_Cursor'Class is abstract;

   function Last (This : Edge_Cursor) return Vertex_Cursor'Class is abstract;

   function Image (This : Edge_Cursor) return String;

   function "<" (L, R : Edge_Cursor'Class) return Boolean;
   --  Uses elements at each for comparison

      --  CONTAINERS

   function "<" (L, R : Vertex_Cursor'Class) return Boolean;
   --  Uses elements at each for comparison

   package Edge_Vectors is
     new Ada.Containers.Indefinite_Vectors (Positive, Edge_Cursor'Class);
   type Edge_Vector is new Edge_Vectors.Vector with null record;

   function Incident (This : Vertex_Cursor) return Edge_Vector'Class
                      is abstract;

   package Vertex_Sets is
     new Ada.Containers.Indefinite_Ordered_Sets (Vertex_Cursor'Class);
   type Vertex_Set is new Vertex_Sets.Set with null record;

   package Vertex_Edge_Type_Maps is
     new Ada.Containers.Indefinite_Ordered_Maps (Vertex_Cursor'Class,
                                                 Edge_Type);

   package Edge_Handles is new Agpl.Generic_Handle (Edge_Cursor'Class);
   type Edge_Handle is new Edge_Handles.Object with null record;

private

   type Graph is abstract tagged null record;

end Agpl.Containers.Graphs;