summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-04-30 12:06:58 +1000
committerJed Barber <jjbarber@y7mail.com>2020-04-30 12:06:58 +1000
commit15f53e4b81c7f9d5437295ecfc5d7900ac9a896e (patch)
tree27aeec8a44d2b47c5a3d84e2227266f884ea6197 /src
parentf9bc26ce709fcd83288fb6298741dd10bda66a8b (diff)
Node Swap now allows labels to follow the nodes they're attached to
Diffstat (limited to 'src')
-rw-r--r--src/directed_graphs.adb20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/directed_graphs.adb b/src/directed_graphs.adb
index 3446247..9eebcc9 100644
--- a/src/directed_graphs.adb
+++ b/src/directed_graphs.adb
@@ -2148,7 +2148,6 @@ package body Directed_Graphs is
(Container : in out Graph;
Left, Right : in Node_Type)
is
- Temp_Label : Node_Label_Type;
Temp_Vector : Node_Vectors.Vector;
begin
if Impl.Checks then
@@ -2159,22 +2158,6 @@ package body Directed_Graphs is
raise Constraint_Error with "Graph does not contain right operand";
end if;
end if;
- -- Switch labels around, if present
- if Container.Node_Labels.Contains (Left) then
- Temp_Label := Container.Node_Labels.Element (Left);
- if Container.Node_Labels.Contains (Right) then
- Container.Node_Labels.Replace (Left, Container.Node_Labels.Element (Right));
- Container.Node_Labels.Replace (Right, Temp_Label);
- else
- Container.Node_Labels.Insert (Right, Temp_Label);
- Container.Node_Labels.Exclude (Left);
- end if;
- else
- if Container.Node_Labels.Contains (Right) then
- Container.Node_Labels.Insert (Left, Container.Node_Labels.Element (Right));
- Container.Node_Labels.Exclude (Right);
- end if;
- end if;
-- Switch the nodes themselves around
Temp_Vector := Container.Connections.Element (Left);
Container.Connections.Replace (Left, Container.Connections.Element (Right));
@@ -2201,6 +2184,9 @@ package body Directed_Graphs is
if Right.Container = null then
raise Constraint_Error with "Right operand graph does not exist";
end if;
+ if Left.Container /= Right.Container then
+ raise Constraint_Error with "Left and right operands refer to different graphs";
+ end if;
end if;
Left.Container.Swap (Element (Left), Element (Right));
end Swap;