bpp-phyl3  3.0.0
bpp::AwareNode Class Reference

A node class aware of its neighbours. More...

#include <Bpp/Phyl/Legacy/Tree/AwareNode.h>

+ Collaboration diagram for bpp::AwareNode:

Public Member Functions

 AwareNode ()
 Build a new void Node object. More...
 
 AwareNode (unsigned int id)
 Build a new Node with specified id. More...
 
 AwareNode (const AwareNode &node)
 Copy constructor. More...
 
AwareNodeoperator= (const AwareNode &node)
 Assignation operator. More...
 
AwareNodeclone () const
 
virtual ~AwareNode ()
 
template<class N , class E , class I >
void updateTree (AssociationTreeGraphImplObserver< N, E, I > *tree, unsigned int index)
 update information from TreeObserver More...
 
virtual bool hasNoSon () const
 
Identity
virtual unsigned int getId () const
 Get the node's id. More...
 
virtual void setId (unsigned int id)
 Set this node's id. More...
 
virtual std::vector< unsigned int > getSonsId () const
 
Distances:
virtual double getDistanceToFather () const
 Get the distance to the father node is there is one, otherwise throw a NodeException. More...
 
virtual void setDistanceToFather (double distance)
 Set or update the distance toward the father node. More...
 
Father:
virtual const AwareNodegetFather () const
 Get the father of this node is there is one. More...
 
virtual AwareNodegetFather ()
 Get the father of this node is there is one. More...
 
virtual void setFather (AwareNode *node)
 Set the father node of this node. More...
 
virtual void removeFather ()
 Remove the father of this node. More...
 
virtual bool hasFather () const
 Tell if this node has a father node. More...
 
Sons:
virtual size_t getNumberOfSons () const
 
bool isLeaf () const
 
virtual std::vector< AwareNode * > & getSons ()
 
virtual const AwareNodegetSon (size_t pos) const
 
virtual AwareNodegetSon (size_t pos)
 
virtual void addSon (size_t pos, AwareNode *node)
 
virtual void addSon (AwareNode *node)
 
virtual void setSon (size_t pos, AwareNode *node)
 
virtual void removeSon (size_t pos)
 
virtual void removeSon (AwareNode *node)
 
virtual void removeSons ()
 
virtual void swap (size_t branch1, size_t branch2)
 
virtual size_t getSonPosition (const AwareNode *son) const
 
Operators:
  • a positive value send the corresponding son;
  • a negative value send the father.
AwareNodeoperator[] (int i)
 
const AwareNodeoperator[] (int i) const
 

Protected Attributes

unsigned int id_
 
std::vector< AwareNode * > sons_
 
AwareNodefather_
 
double distanceToFather_
 

Detailed Description

A node class aware of its neighbours.

This class is made the more general as possible, while keeping it very simple. It contains:

  • An identity tag, to identity it in the tree;
  • A pointer toward the father node;
  • A std::vector of pointer toward son nodes;
  • The distance from the father node:
See also
PhyloTree

Definition at line 41 of file AwareNode.h.

Constructor & Destructor Documentation

◆ AwareNode() [1/3]

bpp::AwareNode::AwareNode ( )
inline

Build a new void Node object.

Definition at line 54 of file AwareNode.h.

Referenced by clone().

◆ AwareNode() [2/3]

bpp::AwareNode::AwareNode ( unsigned int  id)
inline

Build a new Node with specified id.

Definition at line 64 of file AwareNode.h.

◆ AwareNode() [3/3]

AwareNode::AwareNode ( const AwareNode node)

Copy constructor.

Warning
THIS OPERATOR COPIES ALL FIELDS, EXCEPTED FATHER AND SON NODE POINTERS.

Need the call of updateTree after whole Tree is built.

Parameters
nodeThe node to copy.

Copy constructor:

Definition at line 15 of file AwareNode.cpp.

◆ ~AwareNode()

virtual bpp::AwareNode::~AwareNode ( )
inlinevirtual

Definition at line 98 of file AwareNode.h.

Member Function Documentation

◆ addSon() [1/2]

virtual void bpp::AwareNode::addSon ( AwareNode node)
inlinevirtual

Definition at line 261 of file AwareNode.h.

References sons_.

◆ addSon() [2/2]

virtual void bpp::AwareNode::addSon ( size_t  pos,
AwareNode node 
)
inlinevirtual

Definition at line 251 of file AwareNode.h.

References sons_.

Referenced by swap().

◆ clone()

AwareNode* bpp::AwareNode::clone ( ) const
inline

Definition at line 96 of file AwareNode.h.

References AwareNode().

◆ getDistanceToFather()

virtual double bpp::AwareNode::getDistanceToFather ( ) const
inlinevirtual

Get the distance to the father node is there is one, otherwise throw a NodeException.

Returns
The distance to the father node.

Definition at line 154 of file AwareNode.h.

References distanceToFather_.

◆ getFather() [1/2]

virtual AwareNode* bpp::AwareNode::getFather ( )
inlinevirtual

Get the father of this node is there is one.

Returns
A pointer toward the father node, 0 if there is not.

Definition at line 193 of file AwareNode.h.

References father_.

◆ getFather() [2/2]

virtual const AwareNode* bpp::AwareNode::getFather ( ) const
inlinevirtual

Get the father of this node is there is one.

Returns
A pointer toward the father node, 0 if there is not.

Definition at line 186 of file AwareNode.h.

References father_.

◆ getId()

virtual unsigned int bpp::AwareNode::getId ( ) const
inlinevirtual

Get the node's id.

Returns
The identity tag of this node.

Definition at line 121 of file AwareNode.h.

References id_.

Referenced by getSonPosition(), and removeSon().

◆ getNumberOfSons()

virtual size_t bpp::AwareNode::getNumberOfSons ( ) const
inlinevirtual

Definition at line 227 of file AwareNode.h.

References sons_.

Referenced by hasNoSon(), and isLeaf().

◆ getSon() [1/2]

virtual AwareNode* bpp::AwareNode::getSon ( size_t  pos)
inlinevirtual

Definition at line 245 of file AwareNode.h.

References sons_.

◆ getSon() [2/2]

virtual const AwareNode* bpp::AwareNode::getSon ( size_t  pos) const
inlinevirtual

Definition at line 239 of file AwareNode.h.

References sons_.

Referenced by swap().

◆ getSonPosition()

size_t AwareNode::getSonPosition ( const AwareNode son) const
virtual

Definition at line 51 of file AwareNode.cpp.

References getId(), sons_, and bpp::TextTools::toString().

◆ getSons()

virtual std::vector<AwareNode*>& bpp::AwareNode::getSons ( )
inlinevirtual

Definition at line 234 of file AwareNode.h.

References sons_.

◆ getSonsId()

virtual std::vector<unsigned int> bpp::AwareNode::getSonsId ( ) const
inlinevirtual

Definition at line 130 of file AwareNode.h.

References sons_.

◆ hasFather()

virtual bool bpp::AwareNode::hasFather ( ) const
inlinevirtual

Tell if this node has a father node.

Definition at line 218 of file AwareNode.h.

References father_.

◆ hasNoSon()

virtual bool bpp::AwareNode::hasNoSon ( ) const
inlinevirtual

Definition at line 331 of file AwareNode.h.

References getNumberOfSons().

◆ isLeaf()

bool bpp::AwareNode::isLeaf ( ) const
inline

Definition at line 229 of file AwareNode.h.

References getNumberOfSons().

◆ operator=()

AwareNode & AwareNode::operator= ( const AwareNode node)

Assignation operator.

Warning
THIS OPERATOR COPIES ALL FIELDS, EXCEPTED FATHER AND SON NODE POINTERS.

Need the call of updateTree after whole Tree is built.

Parameters
nodethe node to copy.
Returns
A reference toward this node.

Assignation operator:

Definition at line 23 of file AwareNode.cpp.

References distanceToFather_, father_, id_, and sons_.

◆ operator[]() [1/2]

AwareNode* bpp::AwareNode::operator[] ( int  i)
inline

Definition at line 325 of file AwareNode.h.

References father_, and sons_.

◆ operator[]() [2/2]

const AwareNode* bpp::AwareNode::operator[] ( int  i) const
inline

Definition at line 327 of file AwareNode.h.

References father_, and sons_.

◆ removeFather()

virtual void bpp::AwareNode::removeFather ( )
inlinevirtual

Remove the father of this node.

Definition at line 210 of file AwareNode.h.

References father_.

◆ removeSon() [1/2]

virtual void bpp::AwareNode::removeSon ( AwareNode node)
inlinevirtual

Definition at line 291 of file AwareNode.h.

References getId(), sons_, and bpp::TextTools::toString().

◆ removeSon() [2/2]

virtual void bpp::AwareNode::removeSon ( size_t  pos)
inlinevirtual

Definition at line 284 of file AwareNode.h.

References sons_.

Referenced by swap().

◆ removeSons()

virtual void bpp::AwareNode::removeSons ( )
inlinevirtual

Definition at line 306 of file AwareNode.h.

References sons_.

◆ setDistanceToFather()

virtual void bpp::AwareNode::setDistanceToFather ( double  distance)
inlinevirtual

Set or update the distance toward the father node.

Warning: a distance to the father node may be set even if no father node is specified. This is used by several tree reconstruction methods. It may also be useful for manipulating subtrees.

Parameters
distanceThe new distance to the father node.

Definition at line 168 of file AwareNode.h.

References distanceToFather_.

◆ setFather()

virtual void bpp::AwareNode::setFather ( AwareNode node)
inlinevirtual

Set the father node of this node.

Parameters
nodeThe father node.

Definition at line 202 of file AwareNode.h.

References father_.

◆ setId()

virtual void bpp::AwareNode::setId ( unsigned int  id)
inlinevirtual

Set this node's id.

Parameters
idThe new identity tag.

Definition at line 128 of file AwareNode.h.

References id_.

◆ setSon()

virtual void bpp::AwareNode::setSon ( size_t  pos,
AwareNode node 
)
inlinevirtual

Definition at line 271 of file AwareNode.h.

References sons_.

◆ swap()

void AwareNode::swap ( size_t  branch1,
size_t  branch2 
)
virtual

Sons:

Definition at line 35 of file AwareNode.cpp.

References addSon(), getSon(), and removeSon().

◆ updateTree()

Member Data Documentation

◆ distanceToFather_

double bpp::AwareNode::distanceToFather_
protected

Definition at line 48 of file AwareNode.h.

Referenced by getDistanceToFather(), operator=(), and setDistanceToFather().

◆ father_

AwareNode* bpp::AwareNode::father_
protected

◆ id_

unsigned int bpp::AwareNode::id_
protected

Definition at line 45 of file AwareNode.h.

Referenced by getId(), operator=(), setId(), and updateTree().

◆ sons_

std::vector<AwareNode* > bpp::AwareNode::sons_
protected

The documentation for this class was generated from the following files: