From dc1fe72647f4bd319331113b3971030e241e826a Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Tue, 18 Feb 2025 11:29:09 +0100
Subject: [PATCH] Implement proposal in #212

---
 src/graph/GraphView.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp
index fab9be915..26c693152 100644
--- a/src/graph/GraphView.cpp
+++ b/src/graph/GraphView.cpp
@@ -1115,6 +1115,10 @@ void Aidge::GraphView::insertParent(NodePtr childNode,
 }
 
 bool Aidge::GraphView::replace(const std::set<Aidge::NodePtr>& oldNodes, const std::set<Aidge::NodePtr>& newNodes) {
+    AIDGE_ASSERT(!(oldNodes.size() > 1 && newNodes.size() > 1),
+      "GraphView::replace(): old and new sets cannot both have more than one node (here: {} and {} respectively). Use GraphView instead of set in this case.",
+      oldNodes.size(), newNodes.size());
+
     // (1) create GraphViews from both sets of Nodes
     auto oldG = std::make_shared<GraphView>("oldG");
     oldG->add(oldNodes, false);
-- 
GitLab