Tree Compression with Top Trees Revisited
|
A binary DAG that is specialised to be a top tree's minimal DAG. More...
#include <TopDag.h>
Public Member Functions | |
TopDag (const size_t n, const LabelsT< DataType > &labels) | |
Create a new binary DAG. More... | |
int | addCluster (int left, int right, const MergeType mergeType, const DataType *label=NULL) |
void | finishCreation () |
Call this to clean up temporary data structures once the DAG is final. More... | |
int | countEdges () const |
Count the number of edges in the DAG. More... | |
template<typename T , typename Callback > | |
T | inPostOrder (const Callback &callback) const |
template<typename T , typename Callback > | |
T | traverseDagPostOrder (const int nodeId, const Callback &callback) const |
Helper for inPostOrder(), you shouldn't need to call this directly. More... | |
Public Attributes | |
int | maxClusterId |
vector< DagNode< DataType > > | nodes |
const LabelsT< DataType > & | labels |
std::unordered_map< DagNode< DataType >, int, SubtreeHasher< DataType >, SubtreeEquality< DataType > > | nodeMap |
vector< int > | clusterToDag |
Protected Member Functions | |
int | addCluster_ (int left, int right, const MergeType mergeType, const DataType *label=NULL) |
Add a node. More... | |
int | addNode (int left, int right, MergeType mergeType, const DataType *label) |
void | popNode () |
Remove the last node. More... | |
int | addNodes (const int n) |
Friends | |
std::ostream & | operator<< (std::ostream &os, const TopDag< DataType > &dag) |
A binary DAG that is specialised to be a top tree's minimal DAG.
|
inline |
Add a cluster and return its cluster ID (!= node ID!). If the cluster already exists in the DAG, it is not created again.
left | cluster ID of the left child cluster |
right | cluster ID of the right child cluster |
mergeType | the cluster's merge type |
label | the cluster's label (if any) |
|
inlineprotected |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
|
inline |
Helper for inPostOrder(), you shouldn't need to call this directly.
|
friend |
vector<int> TopDag< DataType >::clusterToDag |
int TopDag< DataType >::maxClusterId |
std::unordered_map<DagNode<DataType>, int, SubtreeHasher<DataType>, SubtreeEquality<DataType> > TopDag< DataType >::nodeMap |