diff --git a/src/graph/GraphView.cpp b/src/graph/GraphView.cpp index d9aef04864310b2c7213229b1563f12cbfccfad2..61520bf159e1d6a50385e0a9c28f64849a3d73c5 100644 --- a/src/graph/GraphView.cpp +++ b/src/graph/GraphView.cpp @@ -1125,6 +1125,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const commonGraphViews.erase(oldGraph); commonGraphViews.erase(newGraph); + //todo this part may give a message such as "input output discrepencies between old and new graphs" before returning false if ((newNodes.size() > 0) && (oldOIn.size() != newOIn.size()) && (oldOOut.size() != newOOut.size())) { for (const auto& nodePtr : oldNodes) { nodePtr->removeView(oldGraph); @@ -1143,6 +1144,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const inputParents[i].first -> addChild(newOIn[i].first, inputParents[i].second, newOIn[i].second); } } + //todo: i'm surprised there's no need for remove child first for (std::size_t o = 0; o < oldOOut.size(); ++o) { for (const auto& child : outputChildren[o]) { newOOut[o].first -> addChild(child.first, newOOut[o].second, child.second); @@ -1154,6 +1156,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const // get the number of Children for oldg->outputNodes() if (newNodes.size() == 0) { // Case 3 + // todo so this case is a big remove and stitch back if (oldOIn.size() == oldOOut.size()) { // Same number of inputs and outputs: connect each input to the corresponding output for (std::size_t i = 0; i < oldOIn.size(); ++i) { @@ -1182,6 +1185,8 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const ((oldOOut.size() == newOOut.size())) ) { // Case 2 + // todo what the heck is this condition? what is that case? + // todo how are you supposed to connect all to the same child? if ((oldOIn.size() == 1) && (inputParents[0].first)) { for (std::size_t i = 0; i < newOIn.size(); ++i) { // Only re-connect the same input category @@ -1202,7 +1207,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const } } } - else { + else {// todo add message as to why it's failing for (const auto& nodePtr : oldNodes) { nodePtr->removeView(oldGraph); } @@ -1216,6 +1221,7 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const auto oldGOutputs = oldGraph->outputNodes(); for (const auto& nodePtr : oldNodes) { bool removeFromGraphs = true; + // toddo it seems to check oldGoutput's relevance if (std::find(oldGOutputs.cbegin(), oldGOutputs.cend(), nodePtr) == oldGOutputs.cend()) { for (const auto& chPtr : nodePtr->getChildren()) { if (oldNodes.find(chPtr) == oldNodes.cend()) {