diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index 8e83dff098d3cc355f1d15cc6f0faed5ce563f7a..0e9c906ddcb59106d01495123f5f9bf9b21e5eb2 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -923,11 +923,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const for (std::size_t i = 0; i < oldOIn.size(); ++i) { if (inputParents[i].first) { inputParents[i].first -> addChild(outputChildren[i].first, inputParents[i].second, outputChildren[i].second); - } else { - for (auto & view : commonGraphViews){ - view->setRootNode( outputChildren[i].first); - } - } + } } } else if ((oldOIn.size() == 1) && (inputParents[0].first)) { @@ -937,7 +933,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const } } else if ( // for tiling-like cases. The number of inputNodes changes but not outputNodes - ((oldOIn.size() == 1) || (newOIn.size() == 1)) && // (oldOI.size() == newOI.size()) already handled in Case 1 + ((oldOIn.size() == 1) || (newOIn.size() == 1)) && // (oldOIn.size() == newOI.size()) already handled in Case 1 ((oldOOut.size() == newOOut.size())) ) { // Case 2 @@ -1201,7 +1197,14 @@ void Aidge::GraphView::updateInputsOutputsDelete(std::shared_ptr<Node> deletedNo } if (deletedNode == mRootNode) { - mRootNode = nullptr; + const std::pair<std::vector<NodePtr>, size_t> ranked_nodes = getRankedNodes(); + if(ranked_nodes.second== 0 ) + { + mRootNode = nullptr; + } else { + // The new root node will be the second node in the order of ranked nodes + setRootNode(*std::next(ranked_nodes.first.cbegin(),1)); + } } }