From 15f53e4b81c7f9d5437295ecfc5d7900ac9a896e Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 30 Apr 2020 12:06:58 +1000 Subject: Node Swap now allows labels to follow the nodes they're attached to --- src/directed_graphs.adb | 20 +++----------------- 1 file 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; -- cgit