KrisLibrary  1.0.0
Public Types | Public Member Functions | List of all members
Graph::TreeNode< T, E > Class Template Reference

A tree graph structure, represented directly at the node level. More...

#include <Tree.h>

Inheritance diagram for Graph::TreeNode< T, E >:

Public Types

typedef TreeNode< T, E > MyType
 
typedef CallbackBase< MyType * > Callback
 

Public Member Functions

 TreeNode (const T &t)
 
 TreeNode (const MyType &t)
 
const MyTypeoperator= (const MyType &)
 
MyTypegetParent () const
 
MyTypegetFirstChild () const
 
MyTypegetLastChild () const
 
MyTypegetNextSibling () const
 
E & edgeFromParent ()
 
const E & edgeFromParent () const
 
MyTypeaddChild ()
 
MyTypeaddChild (const T &)
 
MyTypeaddChild (MyType *)
 
MyTypegetChild (int index) const
 
int getChildIndex (MyType *c) const
 
void enumChildren (std::vector< MyType * > &children) const
 
void setChildEdge (MyType *c, const E &) const
 
void detachChild (MyType *)
 
void eraseChild (MyType *)
 
void clearChildren ()
 
bool hasDescendent (const MyType *d) const
 
bool hasAncestor (const MyType *a) const
 
void DFS (Callback &)
 
void BFS (Callback &)
 
void reRoot ()
 
MyTypeLCA (const MyType *n)
 

Detailed Description

template<class T, class E = int>
class Graph::TreeNode< T, E >

A tree graph structure, represented directly at the node level.

Node data T is carried directly as a base class of the TreeNode. Edge data E is carried at the child j of an edge (i,j).

Ensuring the graph is acyclical must be done by the user. If adding node B as a child of A, first check if A is a descendent of B by calling B.hasDescendant(A) or A.hasAncestor(B).

A callbacks for DFS or BFS must be a CallbackBase with a TreeNode<T,E>* as the template argument.


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