KrisLibrary
1.0.0
|
A tree graph structure, represented directly at the node level. More...
#include <Tree.h>
Public Types | |
typedef TreeNode< T, E > | MyType |
typedef CallbackBase< MyType * > | Callback |
Public Member Functions | |
TreeNode (const T &t) | |
TreeNode (const MyType &t) | |
const MyType & | operator= (const MyType &) |
MyType * | getParent () const |
MyType * | getFirstChild () const |
MyType * | getLastChild () const |
MyType * | getNextSibling () const |
E & | edgeFromParent () |
const E & | edgeFromParent () const |
MyType * | addChild () |
MyType * | addChild (const T &) |
MyType * | addChild (MyType *) |
MyType * | getChild (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 () |
MyType * | LCA (const MyType *n) |
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.