Tree Compression with Top Trees Revisited
Public Member Functions | Public Attributes | Friends | List of all members
TopTree< DataType > Struct Template Reference

Top tree data structure. More...

#include <TopTree.h>

Collaboration diagram for TopTree< DataType >:
Collaboration graph
[legend]

Public Member Functions

 TopTree (const int numLeaves, LabelsT< DataType > &labels)
 
 TopTree (const int numLeaves)
 
int addCluster (const int left, const int right, const MergeType mergeType)
 
template<typename Callback >
void inPostOrder (const Callback &callback)
 
template<typename Callback >
void traverseTreePostOrder (const int clusterId, const Callback &callback)
 Helper for inPostOrder, you shouldn't need to use this. More...
 
template<typename T , typename Callback >
foldPostOrder (const Callback &callback, const T initial) const
 
template<typename T , typename Callback >
traverseFoldPostOrder (const int clusterId, const Callback &callback, const T initial) const
 Helper function for foldPostOrder(). You should not need to use this directly. More...
 
int height () const
 Get the height of the top tree. More...
 
int minDepth () const
 Get the depth of the highest leaf. More...
 
double avgDepth () const
 Get the average depth of all nodes. More...
 
bool isEqual (const TopTree< DataType > &other) const
 Check equality with another subtree. More...
 
bool nodesEqual (const TopTree< DataType > &other, const int clusterId, const int otherClusterId) const
 Helper for isEqual, you shouldn't need to use this directly. More...
 

Public Attributes

std::vector< Cluster< DataType > > clusters
 
int numLeaves
 

Friends

std::ostream & operator<< (std::ostream &os, const TopTree< DataType > &toptree)
 

Detailed Description

template<typename DataType>
struct TopTree< DataType >

Top tree data structure.

Definition at line 15 of file TopTree.h.

Constructor & Destructor Documentation

template<typename DataType>
TopTree< DataType >::TopTree ( const int  numLeaves,
LabelsT< DataType > &  labels 
)
inline

Create a top tree with labelled leaves

Parameters
numLeavesnumber of leaves in the top tree
labelsthe labels to assign to the leaves

Definition at line 19 of file TopTree.h.

template<typename DataType>
TopTree< DataType >::TopTree ( const int  numLeaves)
inline

Create a top tree with a fixed number of leaves

Parameters
numLeavesthe number of leaves. Not terribly relevant, but other parts use this to do stuff [TM]

Definition at line 28 of file TopTree.h.

Member Function Documentation

template<typename DataType>
int TopTree< DataType >::addCluster ( const int  left,
const int  right,
const MergeType  mergeType 
)
inline

Add a cluster to the top tree

Parameters
leftleft child
rightright child
mergeTypethe type of merge that formed this cluster
Returns
the new cluster's ID

Definition at line 35 of file TopTree.h.

template<typename DataType>
double TopTree< DataType >::avgDepth ( ) const
inline

Get the average depth of all nodes.

Definition at line 97 of file TopTree.h.

template<typename DataType>
template<typename T , typename Callback >
T TopTree< DataType >::foldPostOrder ( const Callback &  callback,
const T  initial 
) const
inline

Traverse the top tree in post order, applying a callback to the callback results of its children

Parameters
callbackfunction to be called on its results of the left and right child
initialvalue to use as "callback result" for leaves

Definition at line 64 of file TopTree.h.

template<typename DataType>
int TopTree< DataType >::height ( ) const
inline

Get the height of the top tree.

Definition at line 83 of file TopTree.h.

template<typename DataType>
template<typename Callback >
void TopTree< DataType >::inPostOrder ( const Callback &  callback)
inline

Traverse the tree in post order

Parameters
callbackcallback to call with the cluster ID as parameter

Definition at line 43 of file TopTree.h.

template<typename DataType>
bool TopTree< DataType >::isEqual ( const TopTree< DataType > &  other) const
inline

Check equality with another subtree.

Definition at line 110 of file TopTree.h.

template<typename DataType>
int TopTree< DataType >::minDepth ( ) const
inline

Get the depth of the highest leaf.

Definition at line 90 of file TopTree.h.

template<typename DataType>
bool TopTree< DataType >::nodesEqual ( const TopTree< DataType > &  other,
const int  clusterId,
const int  otherClusterId 
) const
inline

Helper for isEqual, you shouldn't need to use this directly.

Definition at line 119 of file TopTree.h.

template<typename DataType>
template<typename T , typename Callback >
T TopTree< DataType >::traverseFoldPostOrder ( const int  clusterId,
const Callback &  callback,
const T  initial 
) const
inline

Helper function for foldPostOrder(). You should not need to use this directly.

Definition at line 70 of file TopTree.h.

template<typename DataType>
template<typename Callback >
void TopTree< DataType >::traverseTreePostOrder ( const int  clusterId,
const Callback &  callback 
)
inline

Helper for inPostOrder, you shouldn't need to use this.

Definition at line 49 of file TopTree.h.

Friends And Related Function Documentation

template<typename DataType>
std::ostream& operator<< ( std::ostream &  os,
const TopTree< DataType > &  toptree 
)
friend

Definition at line 156 of file TopTree.h.

Member Data Documentation

template<typename DataType>
std::vector<Cluster<DataType> > TopTree< DataType >::clusters

Definition at line 168 of file TopTree.h.

template<typename DataType>
int TopTree< DataType >::numLeaves

Definition at line 169 of file TopTree.h.


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