From c6fb6381f6590f0eb08bd37ae0c21463aad77fd5 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Wed, 27 Jan 2016 14:17:30 +0100 Subject: [PATCH] Edge can have negative weights in which case they are hidden --- include/hpp/manipulation/graph/node.hh | 10 ++++++++++ src/graph/node.cc | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/include/hpp/manipulation/graph/node.hh b/include/hpp/manipulation/graph/node.hh index e47b9248..16eaf2f3 100644 --- a/include/hpp/manipulation/graph/node.hh +++ b/include/hpp/manipulation/graph/node.hh @@ -55,9 +55,18 @@ namespace hpp { static NodePtr_t create (const std::string& name); /// Create a link from this node to the given node. + /// \deprecated Use Edge->node(NodePtr_t) to give the node. EdgePtr_t linkTo (const std::string& name, const NodePtr_t& to, const Weight_t& w = 1, const bool& isInNodeFrom = false, + EdgeFactory create = Edge::create) + HPP_MANIPULATION_DEPRECATED; + + /// Create a link from this node to the given node. + /// \param w if strictly negative, the edge is not included in the neighbor + /// list. Otherwise, it is included with Weight_t w + EdgePtr_t linkTo (const std::string& name, const NodePtr_t& to, + const size_type& w = 1, EdgeFactory create = Edge::create); /// Check whether the configuration is in this state. @@ -156,6 +165,7 @@ namespace hpp { /// List of possible motions from this state (i.e. the outgoing /// vertices). Neighbors_t neighbors_; + std::vector <EdgePtr_t> hiddenNeighbors_; /// Set of constraints to be statisfied. typedef Cache < ConstraintSetPtr_t > Constraint_t; diff --git a/src/graph/node.cc b/src/graph/node.cc index c6e2429d..50932ea8 100644 --- a/src/graph/node.cc +++ b/src/graph/node.cc @@ -60,6 +60,15 @@ namespace hpp { return newEdge; } + EdgePtr_t Node::linkTo(const std::string& name, const NodePtr_t& to, + const size_type& w, EdgeFactory create) + { + EdgePtr_t newEdge = create(name, graph_, wkPtr_, to); + if (w >= 0) neighbors_.insert (newEdge, (Weight_t)w); + else hiddenNeighbors_.push_back (newEdge); + return newEdge; + } + bool Node::contains (ConfigurationIn_t config) const { return configConstraint()->isSatisfied (config); -- GitLab