diff options
author | Jed Barber <jjbarber@y7mail.com> | 2020-05-21 21:24:25 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2020-05-21 21:24:25 +1000 |
commit | 82a42674ba64c6386152a5910fd7345a92b135e8 (patch) | |
tree | be453540ca12e0679f9ea741f99c592696ce3b96 /src | |
parent | d07979218ea80c58e64148d9638ed3e6195ff6ed (diff) |
Tests complete, minor bugs fixed
Diffstat (limited to 'src')
-rw-r--r-- | src/directed_graphs.adb | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/directed_graphs.adb b/src/directed_graphs.adb index 4b9e823..c690d87 100644 --- a/src/directed_graphs.adb +++ b/src/directed_graphs.adb @@ -226,7 +226,9 @@ package body Directed_Graphs is raise Constraint_Error with "Graph does not contain node"; end if; for A of Container.Connections.Element (Node) loop - Result.Append (A.Node_ID); + if not Result.Contains (A.Node_ID) then + Result.Append (A.Node_ID); + end if; end loop; return V2A (Result); end Children; @@ -454,6 +456,7 @@ package body Directed_Graphs is return False; end if; return Contains_In_Subgraph (Position, Node) and then + Position.Container.Has_Label (Node) and then Position.Container.Constant_Label_Reference (Node) = Label; end Contains_In_Subgraph; @@ -505,6 +508,7 @@ package body Directed_Graphs is return False; end if; return Contains_In_Subgraph (Position, Edge) and then + Position.Container.Has_Label (Edge) and then Position.Container.Constant_Label_Reference (Edge) = Label; end Contains_In_Subgraph; @@ -891,7 +895,7 @@ package body Directed_Graphs is end if; end if; for C in Position.Container.Iterate_Subgraph (Position) loop - Result := Result + Outdegree (Position); + Result := Result + Outdegree (C); end loop; return Result; end Edge_Count_In_Subgraph; @@ -1072,7 +1076,9 @@ package body Directed_Graphs is end if; end if; for C in Position.Container.Iterate_Subgraph (Position) loop - if Position.Container.Node_Labels.Constant_Reference (Element (C)) = Label then + if Position.Container.Has_Label (Element (C)) and then + Position.Container.Node_Labels.Constant_Reference (Element (C)) = Label + then Result.Append (Element (C)); end if; end loop; @@ -1939,13 +1945,18 @@ package body Directed_Graphs is end Next; procedure Next - (Position : in out Cursor) is + (Position : in out Cursor) + is + use type Node_Maps.Cursor; begin if Position.Container = null then Position := No_Element; return; end if; Node_Maps.Next (Position.Place); + if Position.Place = Node_Maps.No_Element then + Position := No_Element; + end if; end Next; function Next @@ -2268,13 +2279,18 @@ package body Directed_Graphs is end Previous; procedure Previous - (Position : in out Cursor) is + (Position : in out Cursor) + is + use type Node_Maps.Cursor; begin if Position.Container = null then Position := No_Element; return; end if; Node_Maps.Previous (Position.Place); + if Position.Place = Node_Maps.No_Element then + Position := No_Element; + end if; end Previous; function Previous |