Skip to content
Snippets Groups Projects
Commit 1de56521 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Removed Node::getNodeDelta()

parent 22f04038
No related branches found
No related tags found
1 merge request!341Error
Pipeline #65505 passed
......@@ -459,17 +459,6 @@ public:
return node->clone();
}
/**
* @brief Get the set of pointers to connected node at a distance of a delta.
* @details the recution are cut
* Return a nullptr is nofing found.
* @param delta Input delta.
* @return std::shared_ptr<Node>
*/
std::set<NodePtr> getNodeDelta(int delta,std::set<Aidge::NodePtr> nodeSee);
#ifdef PYBIND
std::string repr() const {
std::string nodeString{fmt::format("Node(name='{}', optype='{}'", name(), type())};
......
......@@ -454,35 +454,6 @@ Aidge::NodePtr Aidge::Node::clone() const {
return std::make_shared<Node>(mOperator->clone(), std::make_shared<DynamicAttributes>(*mAttrs));
}
std::set<Aidge::NodePtr> Aidge::Node::getNodeDelta(int delta, std::set<Aidge::NodePtr> nodeSee) {
std::set<Aidge::NodePtr> out;
nodeSee.insert(shared_from_this());
if (delta == 0) {
out.insert(shared_from_this());
} else if (delta > 0) {
for (const NodePtr& node : getChildren()) {
if (nodeSee.find(node) == nodeSee.end()) { // loop avoidance
for (const NodePtr& ch : node->getNodeDelta(delta - 1, nodeSee)) {
out.insert(ch);
}
}
}
} else {
for (const NodePtr& node : getParents()) {
if (nodeSee.find(node) == nodeSee.end()) { // loop avoidance
for (const NodePtr& pr : node->getNodeDelta(delta + 1, nodeSee)) {
out.insert(pr);
}
}
}
}
return out;
}
Aidge::Node::~Node() = default;
// namespace Aidge {
......
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include <catch2/catch_test_macros.hpp>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/data/Tensor.hpp"
#include "aidge/graph/GraphView.hpp"
#include "aidge/operator/Conv.hpp"
#include "aidge/operator/GenericOperator.hpp"
#include "aidge/operator/Producer.hpp"
using namespace Aidge;
TEST_CASE("get Delta") {
std::shared_ptr<GraphView> g1 = std::make_shared<GraphView>("TestGraph");
std::shared_ptr<Node> conv = GenericOperator("Conv", 1, 0, 1, "c");
std::shared_ptr<Node> conv1 = GenericOperator("Conv", 1, 0, 1, "c1");
std::shared_ptr<Node> conv2 = GenericOperator("Conv", 1, 0, 1, "c2");
std::shared_ptr<Node> conv3 = GenericOperator("Conv", 1, 0, 1, "c3");
std::shared_ptr<Node> conv3_5 = GenericOperator("Conv", 1, 0, 1, "c3.5");
std::shared_ptr<Node> conv4 = GenericOperator("Conv", 1, 0, 1, "c4");
std::shared_ptr<Node> conv5 = GenericOperator("Conv", 1, 0, 1, "c5");
g1->add(conv);
g1->addChild(conv1, "c");
std::set<Aidge::NodePtr> see;
conv->getNodeDelta(1,see);
SECTION("Self return") {
see.clear();
REQUIRE(conv->getNodeDelta(0,see) == std::set<std::shared_ptr<Node>>{conv});
}
SECTION("child") {
see.clear();
REQUIRE(conv->getNodeDelta(1,see) == std::set<std::shared_ptr<Node>>{conv1});
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment