From baa31dd857a6b196c9fbdd197c22b80d9818ae3a Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 2 May 2020 13:35:50 +1000 Subject: Improved API to allow better manipulation using only Cursors --- src/directed_graphs.ads | 132 ++++++++++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 54 deletions(-) (limited to 'src/directed_graphs.ads') diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads index 17a0239..c8812a9 100644 --- a/src/directed_graphs.ads +++ b/src/directed_graphs.ads @@ -205,6 +205,13 @@ package Directed_Graphs is Edge : in Edge_Type; Label : in Edge_Label_Type); + procedure Insert + (Parent, Child : in out Cursor); + + procedure Insert + (Parent, Child : in out Cursor; + Label : in Edge_Label_Type); + procedure Insert (Container : in out Graph; Edges : in Edge_Array); @@ -233,6 +240,9 @@ package Directed_Graphs is (Container : in out Graph; Edge : in Edge_Type); + procedure Delete + (Parent, Child : in out Cursor); + procedure Delete (Container : in out Graph; Edges : in Edge_Array); @@ -251,6 +261,10 @@ package Directed_Graphs is Edge : in Edge_Type; Label : in Edge_Label_Type); + procedure Append_Label + (Parent, Child : in out Cursor; + Label : in Edge_Label_Type); + procedure Replace_Label (Container : in out Graph; Node : in Node_Type; @@ -265,6 +279,10 @@ package Directed_Graphs is Edge : in Edge_Type; Label : in Edge_Label_Type); + procedure Replace_Label + (Parent, Child : in out Cursor; + Label : in Edge_Label_Type); + procedure Delete_Label (Container : in out Graph; Node : in Node_Type); @@ -276,6 +294,9 @@ package Directed_Graphs is (Container : in out Graph; Edge : in Edge_Type); + procedure Delete_Label + (Parent, Child : in out Cursor); + procedure Delete_Subgraph (Position : in out Cursor); @@ -289,58 +310,6 @@ package Directed_Graphs is - procedure Context - (Container : in Graph; - Node : in Node_Type; - Parents : out Node_Array; - Children : out Node_Array); - - procedure Context - (Position : in Cursor; - Parents : out Node_Array; - Children : out Node_Array); - - procedure Labeled_Context - (Container : in Graph; - Node : in Node_Type; - Parents : out Node_Array; - Children : out Node_Array; - Label : out Node_Label_Type); - - procedure Labeled_Context - (Position : in Cursor; - Parents : out Node_Array; - Children : out Node_Array; - Label : out Node_Label_Type); - - function Has_Label - (Container : in Graph; - Node : in Node_Type) - return Boolean; - - function Has_Label - (Position : in Cursor) - return Boolean; - - function Has_Label - (Container : in Graph; - Edge : in Edge_Type) - return Boolean; - - function Label - (Container : in Graph; - Node : in Node_Type) - return Node_Label_Type; - - function Label - (Position : in Cursor) - return Node_Label_Type; - - function Label - (Container : in Graph; - Edge : in Edge_Type) - return Edge_Label_Type; - type Node_Label_Constant_Reference (Element : not null access constant Node_Label_Type) is private with Implicit_Dereference => Element; @@ -376,6 +345,10 @@ package Directed_Graphs is Edge : in Edge_Type) return Edge_Label_Constant_Reference; + function Constant_Label_Reference + (Parent, Child : in Cursor) + return Edge_Label_Constant_Reference; + type Edge_Label_Reference (Element : not null access Edge_Label_Type) is private with Implicit_Dereference => Element; @@ -385,6 +358,49 @@ package Directed_Graphs is Edge : in Edge_Type) return Edge_Label_Reference; + function Label_Reference + (Parent, Child : in Cursor) + return Edge_Label_Reference; + + + + + function Has_Label + (Container : in Graph; + Node : in Node_Type) + return Boolean; + + function Has_Label + (Position : in Cursor) + return Boolean; + + function Has_Label + (Container : in Graph; + Edge : in Edge_Type) + return Boolean; + + function Has_Label + (Parent, Child : in Cursor) + return Boolean; + + function Label + (Container : in Graph; + Node : in Node_Type) + return Node_Label_Type; + + function Label + (Position : in Cursor) + return Node_Label_Type; + + function Label + (Container : in Graph; + Edge : in Edge_Type) + return Edge_Label_Type; + + function Label + (Parent, Child : in Cursor) + return Edge_Label_Type; + function Neighbors (Container : in Graph; Node : in Node_Type) @@ -609,13 +625,22 @@ package Directed_Graphs is procedure Previous (Position : in out Cursor); + function Follow + (Position : in Cursor; + Edge : in Edge_Type) + return Cursor; + + function Cursor_To + (Position : in Cursor; + Node : in Node_Type) + return Cursor; + private pragma Inline (Append_Label); pragma Inline (Assign); - pragma Inline (Context); pragma Inline (Copy); pragma Inline (Degree); pragma Inline (Delete_Label); @@ -626,7 +651,6 @@ private pragma Inline (Has_Neighbor); pragma Inline (Is_Empty); pragma Inline (Label); - pragma Inline (Labeled_Context); pragma Inline (Move); pragma Inline (Replace_Label); pragma Inline (To_Cursor); -- cgit