bpp-core  2.2.0
bpp::BasicTNode Class Reference

Simple implementation of TNode. More...

#include <Bpp/Graph/BasicTNode.h>

+ Inheritance diagram for bpp::BasicTNode:
+ Collaboration diagram for bpp::BasicTNode:

Public Member Functions

 BasicTNode ()
 Simple constructor. More...
 
virtual ~BasicTNode ()
 Destructor. More...
 
 BasicTNode (const BasicTNode &node)
 Copy constructor. More...
 
BasicTNodeoperator= (const BasicTNode &node)
 Assignation operator. More...
 
BasicTNodeclone () const
 Create a copy of this object and send a pointer to it. More...
 
const BasicTNodegetNeighbor (int pos) const
 Get a neighbor of this node in const context. More...
 
BasicTNodegetNeighbor (int pos)
 Get a neighbor of this node. More...
 
int degree () const
 Get the degree i.e. the number of neighbors of this node. More...
 
const BasicTNodeoperator[] (int i) const
 Direct access to a neighbor in const context. More...
 
BasicTNodeoperator[] (int i)
 Direct access to a neighbor. More...
 
bool hasFather () const
 Tell if the node has a father. More...
 
bool hasFathers () const
 Tell if this node has one or more father nodes. More...
 
int getNumberOfFathers () const
 Give the number of father nodes for this node. More...
 
const BasicTNodegetFather (int pos) const
 Get a particular father in const environment. More...
 
BasicTNodegetFather (int pos)
 Get a particular father. More...
 
const BasicTNodegetFather () const
 Get the father in const environment. More...
 
BasicTNodegetFather ()
 Get the father. More...
 
virtual bool isFather (const BasicTNode *node) const
 Tell if the node is a father of this node. More...
 
virtual void addFather (BasicTNode *node)
 Add a father to this node. More...
 
virtual BasicTNoderemoveFather ()
 Remove the father of this node. More...
 
bool hasSons () const
 Tell if this node has one or more son nodes. More...
 
int getNumberOfSons () const
 Give the number of son nodes for this node. More...
 
const BasicTNodegetSon (int pos) const
 Get a particular son in const environment. More...
 
BasicTNodegetSon (int pos)
 Get a particular son. More...
 
virtual bool isSon (const BasicTNode *node) const
 Tell if a node is son of this node. More...
 
virtual void addSon (BasicTNode *node)
 Add a son to this node. More...
 
virtual void removeSon (BasicTNode *son)
 Remove a son of this node. More...
 
virtual BasicTNoderemoveSon (int pos)
 Remove a son of this node. More...
 

Private Attributes

std::vector< BasicTNode *> sons_
 
BasicTNodefather_
 

Detailed Description

Simple implementation of TNode.

Contains only methods for node manipulation.

Author
Sylvain Gaillard

Definition at line 54 of file BasicTNode.h.

Constructor & Destructor Documentation

◆ BasicTNode() [1/2]

bpp::BasicTNode::BasicTNode ( )
inline

Simple constructor.

Definition at line 63 of file BasicTNode.h.

Referenced by clone().

◆ ~BasicTNode()

BasicTNode::~BasicTNode ( )
virtual

Destructor.

When destroyed, the node remove himself as son of its father and as father of its sons.

Definition at line 48 of file BasicTNode.cpp.

◆ BasicTNode() [2/2]

BasicTNode::BasicTNode ( const BasicTNode node)

Copy constructor.

Definition at line 57 of file BasicTNode.cpp.

Member Function Documentation

◆ addFather()

void BasicTNode::addFather ( BasicTNode node)
virtual

Add a father to this node.

Definition at line 136 of file BasicTNode.cpp.

References addSon(), father_, isFather(), and isSon().

Referenced by addSon().

◆ addSon()

void BasicTNode::addSon ( BasicTNode node)
virtual

Add a son to this node.

Definition at line 181 of file BasicTNode.cpp.

References addFather(), isFather(), isSon(), and sons_.

Referenced by addFather().

◆ clone()

BasicTNode* bpp::BasicTNode::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::TNode.

Definition at line 83 of file BasicTNode.h.

References BasicTNode().

◆ degree()

int bpp::BasicTNode::degree ( ) const
inlinevirtual

Get the degree i.e. the number of neighbors of this node.

Implements bpp::UNode.

Definition at line 92 of file BasicTNode.h.

References father_, and sons_.

◆ getFather() [1/4]

const BasicTNode * BasicTNode::getFather ( int  pos) const
virtual

Get a particular father in const environment.

Implements bpp::TNode.

Definition at line 108 of file BasicTNode.cpp.

References getFather().

◆ getFather() [2/4]

BasicTNode * BasicTNode::getFather ( int  pos)
virtual

Get a particular father.

Implements bpp::TNode.

Definition at line 115 of file BasicTNode.cpp.

References getFather().

◆ getFather() [3/4]

const BasicTNode * BasicTNode::getFather ( ) const
virtual

Get the father in const environment.

Implements bpp::TNode.

Definition at line 122 of file BasicTNode.cpp.

References father_.

Referenced by getFather().

◆ getFather() [4/4]

BasicTNode * BasicTNode::getFather ( )
virtual

Get the father.

Implements bpp::TNode.

Definition at line 126 of file BasicTNode.cpp.

References father_.

◆ getNeighbor() [1/2]

const BasicTNode * BasicTNode::getNeighbor ( int  pos) const
virtual

Get a neighbor of this node in const context.

Parameters
posthe position of the neighbor to get.
Returns
A pointer toward the neighbor node.

Implements bpp::TNode.

Definition at line 70 of file BasicTNode.cpp.

References father_, and sons_.

◆ getNeighbor() [2/2]

BasicTNode * BasicTNode::getNeighbor ( int  pos)
virtual

Get a neighbor of this node.

Parameters
posthe position of the neighbor to get.
Returns
A pointer toward the neighbor node.

Implements bpp::TNode.

Definition at line 80 of file BasicTNode.cpp.

References father_, and sons_.

◆ getNumberOfFathers()

int bpp::BasicTNode::getNumberOfFathers ( ) const
inlinevirtual

Give the number of father nodes for this node.

Implements bpp::ONode.

Definition at line 104 of file BasicTNode.h.

References father_.

◆ getNumberOfSons()

int bpp::BasicTNode::getNumberOfSons ( ) const
inlinevirtual

Give the number of son nodes for this node.

Implements bpp::ONode.

Definition at line 131 of file BasicTNode.h.

References sons_.

◆ getSon() [1/2]

const BasicTNode * BasicTNode::getSon ( int  pos) const
virtual

Get a particular son in const environment.

Implements bpp::TNode.

Definition at line 159 of file BasicTNode.cpp.

References sons_.

◆ getSon() [2/2]

BasicTNode * BasicTNode::getSon ( int  pos)
virtual

Get a particular son.

Implements bpp::TNode.

Definition at line 166 of file BasicTNode.cpp.

References sons_.

◆ hasFather()

bool bpp::BasicTNode::hasFather ( ) const
inline

Tell if the node has a father.

Definition at line 102 of file BasicTNode.h.

References father_.

◆ hasFathers()

bool bpp::BasicTNode::hasFathers ( ) const
inlinevirtual

Tell if this node has one or more father nodes.

Implements bpp::ONode.

Definition at line 103 of file BasicTNode.h.

References father_.

Referenced by removeFather().

◆ hasSons()

bool bpp::BasicTNode::hasSons ( ) const
inlinevirtual

Tell if this node has one or more son nodes.

Implements bpp::ONode.

Definition at line 130 of file BasicTNode.h.

References sons_.

◆ isFather()

bool BasicTNode::isFather ( const BasicTNode node) const
virtual

Tell if the node is a father of this node.

Definition at line 130 of file BasicTNode.cpp.

References father_.

Referenced by addFather(), and addSon().

◆ isSon()

bool BasicTNode::isSon ( const BasicTNode node) const
virtual

Tell if a node is son of this node.

Definition at line 173 of file BasicTNode.cpp.

References sons_.

Referenced by addFather(), and addSon().

◆ operator=()

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

Assignation operator.

Definition at line 62 of file BasicTNode.cpp.

References father_, and sons_.

◆ operator[]() [1/2]

const BasicTNode * BasicTNode::operator[] ( int  i) const
virtual

Direct access to a neighbor in const context.

  • a positive i gives access to sons (from 0 to n - 1)
  • a negative i gives access to fathers (from 1 to m)

No check is done, you have to ensure that you query an existing neighbor.

Parameters
ithe position of the neighbor
Returns
A pointer toward the neighbor

Implements bpp::TNode.

Definition at line 90 of file BasicTNode.cpp.

References father_, and sons_.

◆ operator[]() [2/2]

BasicTNode * BasicTNode::operator[] ( int  i)
virtual

Direct access to a neighbor.

  • a positive i gives access to sons (from 0 to n - 1)
  • a negative i gives access to fathers (from 1 to m)

No check is done, you have to ensure that you query an existing neighbor.

Parameters
ithe position of the neighbor
Returns
A pointer toward the neighbor

Implements bpp::TNode.

Definition at line 98 of file BasicTNode.cpp.

References father_, and sons_.

◆ removeFather()

BasicTNode * BasicTNode::removeFather ( )
virtual

Remove the father of this node.

Returns
A pointer to the removed father node.

Definition at line 147 of file BasicTNode.cpp.

References father_, hasFathers(), and removeSon().

Referenced by removeSon().

◆ removeSon() [1/2]

void BasicTNode::removeSon ( BasicTNode son)
virtual

Remove a son of this node.

Definition at line 190 of file BasicTNode.cpp.

References removeFather(), and sons_.

Referenced by removeFather().

◆ removeSon() [2/2]

BasicTNode * BasicTNode::removeSon ( int  pos)
virtual

Remove a son of this node.

Returns
A pointer to the removed son node or a Null pointer if son is not found.

Definition at line 201 of file BasicTNode.cpp.

References sons_.

Member Data Documentation

◆ father_

BasicTNode* bpp::BasicTNode::father_
private

◆ sons_

std::vector< BasicTNode * > bpp::BasicTNode::sons_
private

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