diff options
author | Jed Barber <jjbarber@y7mail.com> | 2020-05-22 17:42:48 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2020-05-22 17:42:48 +1000 |
commit | 5bb4bfd85fb558380a8b06ac77d0e5b27aee1feb (patch) | |
tree | ad81f63bf4d1cb727e3449fe71c9c0651a6cd808 | |
parent | 82a42674ba64c6386152a5910fd7345a92b135e8 (diff) |
Contains functions now allows Extended_Node_ID_Type input
-rw-r--r-- | src/directed_graphs.adb | 18 | ||||
-rw-r--r-- | src/directed_graphs.ads | 8 | ||||
-rw-r--r-- | test/graph_tests-search.adb | 8 |
3 files changed, 22 insertions, 12 deletions
diff --git a/src/directed_graphs.adb b/src/directed_graphs.adb index c690d87..12916d1 100644 --- a/src/directed_graphs.adb +++ b/src/directed_graphs.adb @@ -370,18 +370,24 @@ package body Directed_Graphs is function Contains (Container : in Graph; - Node : in Node_ID_Type) + Node : in Extended_Node_ID_Type) return Boolean is begin + if Node = No_Node then + return False; + end if; return Container.Connections.Contains (Node); end Contains; function Contains (Container : in Graph; - Node : in Node_ID_Type; + Node : in Extended_Node_ID_Type; Label : in Node_Label_Type) return Boolean is begin + if Node = No_Node then + return False; + end if; return Container.Contains (Node) and then Container.Node_Labels.Contains (Node) and then Container.Node_Labels.Constant_Reference (Node) = Label; @@ -432,10 +438,10 @@ package body Directed_Graphs is function Contains_In_Subgraph (Position : in Cursor; - Node : in Node_ID_Type) + Node : in Extended_Node_ID_Type) return Boolean is begin - if Position.Container = null then + if Position.Container = null or Node = No_Node then return False; end if; for C in Position.Container.Iterate_Subgraph (Position) loop @@ -448,11 +454,11 @@ package body Directed_Graphs is function Contains_In_Subgraph (Position : in Cursor; - Node : in Node_ID_Type; + Node : in Extended_Node_ID_Type; Label : in Node_Label_Type) return Boolean is begin - if Position.Container = null then + if Position.Container = null or Node = No_Node then return False; end if; return Contains_In_Subgraph (Position, Node) and then diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads index d89b647..d31b7c7 100644 --- a/src/directed_graphs.ads +++ b/src/directed_graphs.ads @@ -582,12 +582,12 @@ package Directed_Graphs is function Contains (Container : in Graph; - Node : in Node_ID_Type) + Node : in Extended_Node_ID_Type) return Boolean; function Contains (Container : in Graph; - Node : in Node_ID_Type; + Node : in Extended_Node_ID_Type; Label : in Node_Label_Type) return Boolean; @@ -619,12 +619,12 @@ package Directed_Graphs is function Contains_In_Subgraph (Position : in Cursor; - Node : in Node_ID_Type) + Node : in Extended_Node_ID_Type) return Boolean; function Contains_In_Subgraph (Position : in Cursor; - Node : in Node_ID_Type; + Node : in Extended_Node_ID_Type; Label : in Node_Label_Type) return Boolean; diff --git a/test/graph_tests-search.adb b/test/graph_tests-search.adb index 54b51a4..17c2cbb 100644 --- a/test/graph_tests-search.adb +++ b/test/graph_tests-search.adb @@ -64,7 +64,9 @@ package body Graph_Tests.Search is is Copy_Graph : Graphs.Graph := My_Nonempty_Graph; begin - if Copy_Graph.Contains (Node_ID (20)) or + if Copy_Graph.Contains (Graphs.No_Node) or + Copy_Graph.Contains (Graphs.No_Node, Node_Label (+"ABC")) or + Copy_Graph.Contains (Node_ID (20)) or not Copy_Graph.Contains (Node_ID (2)) or Copy_Graph.Contains (Edge_ID (20)) or not Copy_Graph.Contains (Edge_ID (7)) or @@ -114,7 +116,9 @@ package body Graph_Tests.Search is Branch_1 : Graphs.Cursor := Copy_Graph.To_Cursor (5); Branch_2 : Graphs.Cursor := Copy_Graph.To_Cursor (2); begin - if Graphs.Contains_In_Subgraph (Branch_1, Node_ID (2)) or + if Graphs.Contains_In_Subgraph (Branch_1, Graphs.No_Node) or + Graphs.Contains_In_Subgraph (Branch_1, Graphs.No_Node, Node_Label (+"ABC")) or + Graphs.Contains_In_Subgraph (Branch_1, Node_ID (2)) or not Graphs.Contains_In_Subgraph (Branch_1, Node_ID (10)) or Graphs.Contains_In_Subgraph (Branch_1, (2, 2, 3)) or not Graphs.Contains_In_Subgraph (Branch_1, (13, 7, 5)) or |