diff options
author | Jed Barber <jjbarber@y7mail.com> | 2020-04-28 00:32:55 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2020-04-28 00:32:55 +1000 |
commit | 05d903360247c57cd0db740ff1cb04ee39a1cb2e (patch) | |
tree | 19bc8bcd615d9a318dcf24f253e08f9a340a58ab /src/directed_graphs.ads | |
parent | 01a397b9c565e60171434e2b2d0d694d8a54b1e8 (diff) |
All functionality done except for isomorphism?
Diffstat (limited to 'src/directed_graphs.ads')
-rw-r--r-- | src/directed_graphs.ads | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads index 98b19af..73e34ff 100644 --- a/src/directed_graphs.ads +++ b/src/directed_graphs.ads @@ -63,6 +63,10 @@ package Directed_Graphs is (Position : in Cursor) return Boolean; + function Element + (Position : in Cursor) + return Node_Type; + package Graph_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); @@ -72,6 +76,10 @@ package Directed_Graphs is (Left, Right : in Graph) return Boolean; + function Isomorphic + (Left, Right : in Cursor) + return Boolean; + function To_Graph (Nodes : in Node_Array; Edges : in Edge_Array) @@ -116,18 +124,34 @@ package Directed_Graphs is (Container : in Graph) return Ada.Containers.Count_Type; + function Node_Count + (Position : in Cursor) + return Ada.Containers.Count_Type; + function Edge_Count (Container : in Graph) return Ada.Containers.Count_Type; + function Edge_Count + (Position : in Cursor) + return Ada.Containers.Count_Type; + function Nodes (Container : in Graph) return Node_Array; + function Nodes + (Position : in Cursor) + return Node_Array; + function Edges (Container : in Graph) return Edge_Array; + function Edges + (Position : in Cursor) + return Edge_Array; + procedure Node_Range (Container : in Graph; Minimum : out Node_Type; @@ -317,8 +341,8 @@ package Directed_Graphs is with Implicit_Dereference => Element; function Label_Reference - (Container : in Graph; - Node : in Node_Type) + (Container : aliased in out Graph; + Node : in Node_Type) return Node_Label_Reference; function Label_Reference @@ -339,8 +363,8 @@ package Directed_Graphs is with Implicit_Dereference => Element; function Label_Reference - (Container : in Graph; - Edge : in Edge_Type) + (Container : aliased in out Graph; + Edge : in Edge_Type) return Edge_Label_Reference; function Neighbors @@ -572,14 +596,23 @@ private + -- These need to be replaced with my own nested packages with + -- separate bodies, as Ada.Containers.Helpers is GNAT-specific package Help renames Ada.Containers.Helpers; package Impl is new Help.Generic_Implementation; + package Streams renames Ada.Streams; package Node_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Node_Type); + package Vector_Sort is new Node_Vectors.Generic_Sorting; + + package Edge_Vectors is new Ada.Containers.Vectors + (Index_Type => Positive, + Element_Type => Edge_Type); + function To_Hash (Node : in Node_Type) return Ada.Containers.Hash_Type; @@ -619,9 +652,6 @@ private Tamper_Info : aliased Help.Tamper_Counts; end record; - overriding procedure Adjust - (Container : in out Graph); - overriding procedure Finalize (Container : in out Graph); @@ -645,6 +675,8 @@ private type Cursor is record Container : Graph_Access; Node : Node_Type := Node_Type'First; + Visited : Node_Vectors.Vector; + Path_Up : Node_Vectors.Vector; end record; procedure Write @@ -657,7 +689,11 @@ private Position : out Cursor); for Cursor'Read use Read; - No_Element : constant Cursor := Cursor'(null, Node_Type'First); + No_Element : constant Cursor := + (Container => null, + Node => Node_Type'First, + Visited => Node_Vectors.Empty_Vector, + Path_Up => Node_Vectors.Empty_Vector); @@ -739,7 +775,6 @@ private Graph_Iterator_Interfaces.Reversible_Iterator with record Container : Graph_Access; - Node : Extended_Node_Type; end record with Disable_Controlled => not Impl.T_Check; @@ -772,8 +807,6 @@ private record Container : Graph_Access; Root_Node : Node_Type; - Visited : Node_Vectors.Vector; - Current : Extended_Node_Type; end record with Disable_Controlled => not Impl.T_Check; |