5 #ifndef BPP_PHYL_TREE_NODE_H
6 #define BPP_PHYL_TREE_NODE_H
99 Node(
const std::string& name) :
101 name_(new std::string(name)),
112 Node(
int id,
const std::string& name) :
114 name_(new std::string(name)),
181 std::vector<int> sonsId(
sons_.size());
182 for (
size_t i = 0; i <
sons_.size(); i++)
184 sonsId[i] =
sons_[i]->getId();
217 name_ =
new std::string(name);
253 throw NodePException(
"Node::getDistanceToFather: Node has no distance.",
this);
327 if (find(node->
sons_.begin(), node->
sons_.end(),
this) == node->
sons_.end())
328 node->
sons_.push_back(
this);
330 std::cerr <<
"DEVEL warning: Node::setFather. Son node already registered! No pb here, but could be a bug in your implementation..." << std::endl;
379 sons_.insert(
sons_.begin() +
static_cast<ptrdiff_t
>(pos), node);
381 std::cerr <<
"DEVEL warning: Node::addSon. Son node already registered! No pb here, but could be a bug in your implementation..." << std::endl;
391 sons_.push_back(node);
393 throw NodePException(
"Node::addSon. Trying to add a node which is already present.");
401 if (pos >=
sons_.size())
403 std::vector<Node*>::iterator search = find(
sons_.begin(),
sons_.end(), node);
404 if (search ==
sons_.end() || search ==
sons_.begin() +
static_cast<ptrdiff_t
>(pos))
407 throw NodePException(
"Node::setSon. Trying to set a node which is already present.");
413 if (pos >=
sons_.size())
416 sons_.erase(
sons_.begin() +
static_cast<ptrdiff_t
>(pos));
425 for (
size_t i = 0; i <
sons_.size(); i++)
427 if (
sons_[i] == node)
429 sons_.erase(
sons_.begin() +
static_cast<ptrdiff_t
>(i));
439 while (
sons_.size() != 0)
443 virtual void swap(
size_t branch1,
size_t branch2);
Exception thrown when something is wrong with a particular node.
General exception thrown when something is wrong with a particular node.
The phylogenetic node class.
Node(int id)
Build a new Node with specified id.
virtual void deleteNodeProperties()
Delete all node properties.
virtual void setSon(size_t pos, Node *node)
virtual void deleteName()
Delete the name associated to this node (do nothing if there is no name).
virtual std::string getName() const
Get the name associated to this node, if there is one, otherwise throw a NodeException.
Node(const std::string &name)
Build a new Node with specified name.
virtual Clonable * getNodeProperty(const std::string &name)
virtual void setDistanceToFather(double distance)
Set or update the distance toward the father node.
virtual Node * removeSon(size_t pos)
virtual void deleteDistanceToFather()
Delete the distance to the father node.
virtual int getId() const
Get the node's id.
virtual bool hasBranchProperty(const std::string &name) const
virtual void setId(int id)
Set this node's id.
std::map< std::string, Clonable * > branchProperties_
virtual const Clonable * getNodeProperty(const std::string &name) const
virtual void addSon(size_t pos, Node *node)
Node(int id, const std::string &name)
Build a new Node with specified id and name.
virtual std::vector< Node * > & getSons()
Node & operator=(const Node &node)
Assignation operator.
virtual bool hasBootstrapValue() const
virtual const Node * getSon(size_t pos) const
virtual void setBranchProperty(const std::string &name, const Clonable &property)
Set/add a branch property.
virtual const Node * getFather() const
Get the father of this node is there is one.
virtual bool hasDistanceToFather() const
Tell is this node has a distance to the father.
virtual Node * getFather()
Get the father of this node is there is one.
Node()
Build a new void Node object.
std::vector< Node * > sons_
virtual Clonable * removeBranchProperty(const std::string &name)
virtual void setNodeProperty(const std::string &name, const Clonable &property)
Set/add a node property.
virtual Clonable * removeNodeProperty(const std::string &name)
virtual void removeSons()
virtual bool hasNoSon() const
virtual const Clonable * getBranchProperty(const std::string &name) const
virtual void removeSon(Node *node)
virtual Node * getSon(size_t pos)
virtual bool isLeaf() const
virtual size_t getSonPosition(const Node *son) const
virtual void deleteNodeProperty(const std::string &name)
void addSubTree(const PhyloTree &tree, std::shared_ptr< PhyloNode > phyloNode)
virtual bool operator==(const Node &node) const
virtual std::vector< int > getSonsId() const
std::vector< const Node * > getNeighbors() const
virtual Clonable * getBranchProperty(const std::string &name)
virtual void swap(size_t branch1, size_t branch2)
virtual void removeNodeProperties()
Remove all node properties.
virtual Node * removeFather()
Remove the father of this node.
virtual void deleteBranchProperty(const std::string &name)
virtual bool hasFather() const
Tell if this node has a father node.
virtual void setName(const std::string &name)
Give a name or update the name associated to the node.
double * distanceToFather_
const Node * operator[](int i) const
virtual double getBootstrapValue() const
virtual void deleteBranchProperties()
Delete all branch properties.
virtual std::vector< std::string > getBranchPropertyNames() const
virtual void addSon(Node *node)
virtual bool hasName() const
Tell is this node has a name.
virtual std::vector< std::string > getNodePropertyNames() const
virtual void setFather(Node *node)
Set the father node of this node.
virtual bool hasNodeProperty(const std::string &name) const
std::map< std::string, Clonable * > nodeProperties_
virtual double getDistanceToFather() const
Get the distance to the father node is there is one, otherwise throw a NodeException.
virtual void removeBranchProperties()
Remove all branch properties.
virtual int getFatherId() const
virtual size_t getNumberOfSons() const
virtual size_t degree() const
General exception thrown if a property could not be found.
Defines the basic types of data flow nodes.