Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qgar::GenNode< TNODE, TEDGE > Class Template Reference
[Graphs and trees]

#include <qgarlib/GenNode.H>

List of all members.


Detailed Description

template<class TNODE, class TEDGE>
class qgar::GenNode< TNODE, TEDGE >

Node of a parameterized graph containing (user-defined) data.

A node includes:

See class qgar::GenEdge for edges.

Warning:
Author:
Gérald Masini
Date:
July 29, 2004 17:18
Since:
Qgar 2.1.2

Definition at line 85 of file GenNode.H.

Public Types

Types
typedef TEDGE edge_type
 Type of the data stored in an edge.
typedef edge_typeedge_type_reference
 Reference to qgar::GenEdge::edge_type.
typedef const edge_typeedge_type_const_reference
 Constant reference to qgar::GenEdge::edge_type.
typedef edge_typeedge_type_pointer
 Pointer to qgar::GenEdge::edge_type.
typedef const edge_typeedge_type_const_pointer
 Constant pointer to qgar::GenEdge::edge_type.
typedef TNODE node_type
 Type of the data stored in a node.
typedef node_typenode_type_reference
 Reference to qgar::GenEdge::node_type.
typedef const node_typenode_type_const_reference
 Constant reference to qgar::GenEdge::node_type.
typedef node_typenode_type_pointer
 Pointer to qgar::GenEdge::node_type.
typedef const node_typenode_type_const_pointer
 Constant pointer to qgar::GenEdge::node_type.

Public Member Functions

Constructors
 GenNode (short int aFlag=0)
 Default constructor.
 GenNode (node_type_const_reference aData, short int aFlag=0)
 Initialize with data.
 GenNode (GenEdge< node_type, edge_type > *const aPEdge, node_type_const_reference aData, short int aFlag=0)
 Initialize with a pointer to an edge, and data.
 GenNode (GenEdge< node_type, edge_type > *const aPEdge1, GenEdge< node_type, edge_type > *const aPEdge2, node_type_const_reference aData, short int aFlag=0)
 Initialize with two pointers to an edge, and data.
 GenNode (GenEdge< node_type, edge_type > *const aPEdge1, GenEdge< node_type, edge_type > *const aPEdge2, GenEdge< node_type, edge_type > *const aPEdge3, node_type_const_reference aData, short int aFlag=0)
 Initialize with three pointers to an edge, and data.
 GenNode (const GenNode< node_type, edge_type > &aNode)
 Copy constructor.
Destructor
 ~GenNode ()
 Non-virtual destructor.
Node characteristics
int degree () const
 Get node degree (number of edges adjacent to the node).
Node data
node_type_const_reference accessData () const
 Get node data.
node_type data () const
 Get a copy of the node data.
void setData (node_type_const_reference aData)
 Set node data.
short int flag () const
 Get node flag.
void setFlag (short int aFlag)
 Set node flag.
Access to edges
const std::list< GenEdge<
node_type, edge_type > * > & 
accessEdges () const
 Get (a constant reference to) the edges list.
std::list< GenEdge< node_type,
edge_type > * > & 
getEdges ()
 Get the edges list.
std::list< GenEdge< node_type,
edge_type > * > 
edges () const
 Get a copy of the edges list.
Edge insertion
GenEdge< node_type, edge_type > * addEdge (GenEdge< node_type, edge_type > *const aPEdge)
 Add a created edge from given data and flag, and return a pointer to it.Add (a pointer to) an edge at the end of the edges list of the node.
GenEdge< node_type, edge_type > * addEdgeFront (GenEdge< node_type, edge_type > *const aPEdge)
 Add (a pointer to) an edge at the beginning of the edges list of the node.
Edge removal
Warning: The client is in charge of the deletion of the removed elements. Removals invalidate iterators pointing to removed elements.

GenEdge< node_type, edge_type > * removeEdge (typename std::list< GenEdge< node_type, edge_type > * >::iterator aPos)
 Remove the edge at given position in the edges list, and return it.
GenEdge< node_type, edge_type > * removeEdge (GenEdge< node_type, edge_type > *const aPEdge)
 Remove the first pointer to an edge that compares equal to the given pointer in the edges list.
Operators
GenNode< node_type, edge_type > & operator= (const GenNode< node_type, edge_type > &aNode)
 Assignment.
bool operator== (const GenNode< node_type, edge_type > &aNode)
 Equality.
bool operator!= (const GenNode< node_type, edge_type > &aNode)
 Inequality.

Protected Attributes

Representation of a node
node_type _data
 Data contained in the node.
short int _flag
 Flag at client's disposal (default 0).
std::list< GenEdge< node_type,
edge_type > * > 
_edges
 List of (pointers to) edges adjacent to the node.


Member Typedef Documentation

template<class TNODE, class TEDGE>
typedef TEDGE qgar::GenNode< TNODE, TEDGE >::edge_type
 

Type of the data stored in an edge.

Definition at line 99 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef const edge_type* qgar::GenNode< TNODE, TEDGE >::edge_type_const_pointer
 

Constant pointer to qgar::GenEdge::edge_type.

Definition at line 119 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef const edge_type& qgar::GenNode< TNODE, TEDGE >::edge_type_const_reference
 

Constant reference to qgar::GenEdge::edge_type.

Definition at line 109 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef edge_type* qgar::GenNode< TNODE, TEDGE >::edge_type_pointer
 

Pointer to qgar::GenEdge::edge_type.

Definition at line 114 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef edge_type& qgar::GenNode< TNODE, TEDGE >::edge_type_reference
 

Reference to qgar::GenEdge::edge_type.

Definition at line 104 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef TNODE qgar::GenNode< TNODE, TEDGE >::node_type
 

Type of the data stored in a node.

Definition at line 124 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef const node_type* qgar::GenNode< TNODE, TEDGE >::node_type_const_pointer
 

Constant pointer to qgar::GenEdge::node_type.

Definition at line 144 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef const node_type& qgar::GenNode< TNODE, TEDGE >::node_type_const_reference
 

Constant reference to qgar::GenEdge::node_type.

Definition at line 134 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef node_type* qgar::GenNode< TNODE, TEDGE >::node_type_pointer
 

Pointer to qgar::GenEdge::node_type.

Definition at line 139 of file GenNode.H.

template<class TNODE, class TEDGE>
typedef node_type& qgar::GenNode< TNODE, TEDGE >::node_type_reference
 

Reference to qgar::GenEdge::node_type.

Definition at line 129 of file GenNode.H.


Constructor & Destructor Documentation

template<class TNODE, class TEDGE>
qgar::GenNode< TNODE, TEDGE >::GenNode short int  aFlag = 0  ) 
 

Default constructor.

The edges list of the node is empty.

Parameters:
aFlag value of the node flag (default 0)

Definition at line 51 of file GenNode.TCC.

template<class TNODE, class TEDGE>
qgar::GenNode< TNODE, TEDGE >::GenNode node_type_const_reference  aData,
short int  aFlag = 0
 

Initialize with data.

The edges list of the node is empty.

Parameters:
aData data to be contained in the node
aFlag value of the node flag (default 0)

template<class TNODE, class TEDGE>
qgar::GenNode< TNODE, TEDGE >::GenNode GenEdge< node_type, edge_type > *const   aPEdge,
node_type_const_reference  aData,
short int  aFlag = 0
 

Initialize with a pointer to an edge, and data.

The pointer to the edge is inserted in the edges list of the node.

Parameters:
aPEdge pointer to an edge: Should not be 0!
aData data to be contained in the node
aFlag value of the node flag (default 0)

template<class TNODE, class TEDGE>
qgar::GenNode< TNODE, TEDGE >::GenNode GenEdge< node_type, edge_type > *const   aPEdge1,
GenEdge< node_type, edge_type > *const   aPEdge2,
node_type_const_reference  aData,
short int  aFlag = 0
 

Initialize with two pointers to an edge, and data.

The pointers to edges are inserted in the edges list of the node.

Parameters:
aPEdge1 pointer to an edge Should not be 0!
aPEdge2 pointer to an edge Should not be 0!
aData data to be contained in the node
aFlag value of the node flag (default 0)

template<class TNODE, class TEDGE>
qgar::GenNode< TNODE, TEDGE >::GenNode GenEdge< node_type, edge_type > *const   aPEdge1,
GenEdge< node_type, edge_type > *const   aPEdge2,
GenEdge< node_type, edge_type > *const   aPEdge3,
node_type_const_reference  aData,
short int  aFlag = 0
 

Initialize with three pointers to an edge, and data.

The pointers to edges are inserted in the edges list of the node.

Parameters:
aPEdge1 pointer to an edge Should not be 0!
aPEdge2 pointer to an edge Should not be 0!
aPEdge3 pointer to an edge Should not be 0!
aData data to be contained in the node
aFlag value of the node flag (default 0)

template<class TNODE, class TEDGE>
qgar::GenNode< TNODE, TEDGE >::GenNode const GenNode< node_type, edge_type > &  aNode  ) 
 

Copy constructor.

Parameters:
aNode a node to be copied
Warning:
The constructor performs a shallow copy: The edges adjacent to the node are not duplicated.
Todo:
This constructor performs a shallow copy. Could it perform a deep copy? Edges adjacent to the node would thus be copied, and then all nodes adjacent to these edges, and the edges adjacent to these nodes... and then the whole graph!

template<class TNODE, class TEDGE>
qgar::GenNode< TNODE, TEDGE >::~GenNode  ) 
 

Non-virtual destructor.

Definition at line 155 of file GenNode.TCC.


Member Function Documentation

template<class TNODE, class TEDGE>
const TNODE & qgar::GenNode< TNODE, TEDGE >::accessData  )  const [inline]
 

Get node data.

Definition at line 189 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_data.

template<class TNODE, class TEDGE>
const std::list< GenEdge< TNODE, TEDGE > * > & qgar::GenNode< TNODE, TEDGE >::accessEdges  )  const [inline]
 

Get (a constant reference to) the edges list.

Definition at line 244 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges.

template<class TNODE, class TEDGE>
GenEdge< TNODE, TEDGE > * qgar::GenNode< TNODE, TEDGE >::addEdge GenEdge< node_type, edge_type > *const   aPEdge  )  [inline]
 

Add a created edge from given data and flag, and return a pointer to it.Add (a pointer to) an edge at the end of the edges list of the node.

Iterators to the edges list are not invalidated.

Parameters:
aPEdge a pointer to an edge: Should not be 0!

Definition at line 279 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges.

template<class TNODE, class TEDGE>
GenEdge< TNODE, TEDGE > * qgar::GenNode< TNODE, TEDGE >::addEdgeFront GenEdge< node_type, edge_type > *const   aPEdge  )  [inline]
 

Add (a pointer to) an edge at the beginning of the edges list of the node.

Iterators to the edges list are not invalidated.

Parameters:
aPEdge a pointer to an edge: Should not be 0!

Definition at line 295 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges.

template<class TNODE, class TEDGE>
TNODE qgar::GenNode< TNODE, TEDGE >::data  )  const [inline]
 

Get a copy of the node data.

Definition at line 199 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_data.

template<class TNODE, class TEDGE>
int qgar::GenNode< TNODE, TEDGE >::degree  )  const [inline]
 

Get node degree (number of edges adjacent to the node).

Definition at line 174 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges.

template<class TNODE, class TEDGE>
std::list< GenEdge< TNODE, TEDGE > * > qgar::GenNode< TNODE, TEDGE >::edges  )  const [inline]
 

Get a copy of the edges list.

Definition at line 264 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges.

template<class TNODE, class TEDGE>
short int qgar::GenNode< TNODE, TEDGE >::flag  )  const [inline]
 

Get node flag.

Definition at line 219 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_flag.

template<class TNODE, class TEDGE>
std::list< GenEdge< TNODE, TEDGE > * > & qgar::GenNode< TNODE, TEDGE >::getEdges  )  [inline]
 

Get the edges list.

Definition at line 254 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges.

template<class TNODE, class TEDGE>
bool qgar::GenNode< TNODE, TEDGE >::operator!= const GenNode< node_type, edge_type > &  aNode  )  [inline]
 

Inequality.

Tests if the data of the current node do not compare equal to the data of given node aNode, using operator != applying to objects of type TNODE, The values of the flags are not taken into account.

Parameters:
aNode a node

template<class TNODE, class TEDGE>
GenNode<node_type,edge_type>& qgar::GenNode< TNODE, TEDGE >::operator= const GenNode< node_type, edge_type > &  aNode  ) 
 

Assignment.

Parameters:
aNode node to be assigned
Warning:
The function performs a shallow copy: The edges adjacent to the node are not duplicated.
Todo:
This constructor performs a shallow copy. Could it perform a deep copy? Edges adjacent to the node would thus be copied, and then all nodes adjacent to these edges, and the edges adjacent to these nodes... and then the whole graph!

template<class TNODE, class TEDGE>
bool qgar::GenNode< TNODE, TEDGE >::operator== const GenNode< node_type, edge_type > &  aNode  )  [inline]
 

Equality.

Tests if the data of the current node compare equal to the data of given node aNode, using operator <b>== applying to objects of type TNODE, The values of the flags are not taken into account.

Parameters:
aNode a node

template<class TNODE, class TEDGE>
GenEdge< TNODE, TEDGE > * qgar::GenNode< TNODE, TEDGE >::removeEdge GenEdge< node_type, edge_type > *const   aPEdge  ) 
 

Remove the first pointer to an edge that compares equal to the given pointer in the edges list.

The function return the given pointer if the removal is performed, 0 otherwise.

Parameters:
aPEdge a pointer to an edge: Should not be 0!

Definition at line 329 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges, and qgar::GenNode< TNODE, TEDGE >::removeEdge().

template<class TNODE, class TEDGE>
GenEdge< TNODE, TEDGE > * qgar::GenNode< TNODE, TEDGE >::removeEdge typename std::list< GenEdge< node_type, edge_type > * >::iterator  aPos  ) 
 

Remove the edge at given position in the edges list, and return it.

No effect when aPos points to the end of the list.

Parameters:
aPos a position in the STL list of adjacent edges

Definition at line 315 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_edges.

Referenced by qgar::GenNode< TNODE, TEDGE >::removeEdge().

template<class TNODE, class TEDGE>
void qgar::GenNode< TNODE, TEDGE >::setData node_type_const_reference  aData  )  [inline]
 

Set node data.

Parameters:
aData data to be contained in the node

template<class TNODE, class TEDGE>
void qgar::GenNode< TNODE, TEDGE >::setFlag short int  aFlag  )  [inline]
 

Set node flag.

Parameters:
aFlag value to assign to the flag

Definition at line 229 of file GenNode.TCC.

References qgar::GenNode< TNODE, TEDGE >::_flag.


Member Data Documentation

template<class TNODE, class TEDGE>
node_type qgar::GenNode< TNODE, TEDGE >::_data [protected]
 

Data contained in the node.

Definition at line 464 of file GenNode.H.

Referenced by qgar::GenNode< TNODE, TEDGE >::accessData(), and qgar::GenNode< TNODE, TEDGE >::data().

template<class TNODE, class TEDGE>
std::list< GenEdge<node_type,edge_type>* > qgar::GenNode< TNODE, TEDGE >::_edges [protected]
 

List of (pointers to) edges adjacent to the node.

Definition at line 474 of file GenNode.H.

Referenced by qgar::GenNode< TNODE, TEDGE >::accessEdges(), qgar::GenNode< TNODE, TEDGE >::addEdge(), qgar::GenNode< TNODE, TEDGE >::addEdgeFront(), qgar::GenNode< TNODE, TEDGE >::degree(), qgar::GenNode< TNODE, TEDGE >::edges(), qgar::GenNode< TNODE, TEDGE >::getEdges(), and qgar::GenNode< TNODE, TEDGE >::removeEdge().

template<class TNODE, class TEDGE>
short int qgar::GenNode< TNODE, TEDGE >::_flag [protected]
 

Flag at client's disposal (default 0).

Definition at line 469 of file GenNode.H.

Referenced by qgar::GenNode< TNODE, TEDGE >::flag(), and qgar::GenNode< TNODE, TEDGE >::setFlag().


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