29 int main(
int argc,
char **argv) {
31 const bool useRePair = argParser.
isSet(
"r");
32 string filename =
"data/1998statistics.xml";
35 }
else if (useRePair) {
37 string arg = argParser.
get<
string>(
"r",
"");
38 filename = (arg ==
"") ? filename : arg;
40 const double minRatio = argParser.
get<
double>(
"m", 1.26);
47 std::cout <<
"Could not parse input file, aborting" << std::endl;
52 const double origAvgDepth(t.
avgDepth());
53 cout << t.
summary() <<
"; Height: " << origHeight <<
" Avg depth: " << origAvgDepth << endl;
61 topDagConstructor.
construct(NULL, minRatio);
66 cout <<
"Top DAG construction took " << timer.
getAndReset() <<
"ms" << endl;
75 const double edgePercentage = (edges * 100.0) / origEdges;
76 const double nodePercentage = (nodes * 100.0) / origNodes;
77 const double ratio = ((int)(1000 / edgePercentage)) / 10.0;
78 cout <<
"Top dag has " << nodes <<
" nodes (" << nodePercentage <<
"%), "
79 << edges <<
" edges (" << edgePercentage <<
"% of original tree, " << ratio <<
":1)" << endl;
83 const std::streamsize precision = cout.precision();
84 cout <<
"Output file needs " << bits <<
" bits (" << (bits+7)/8 <<
" bytes), vs " << (treeSize+7)/8 <<
" bytes for orig succ tree, "
85 << std::fixed << std::setprecision(1) << (double)treeSize/bits <<
":1" << endl;
86 cout.unsetf(std::ios_base::fixed);
87 cout << std::setprecision(precision);
90 <<
" compressed=" << bits
91 <<
" succinct=" << treeSize
92 <<
" minRatio=" << minRatio
93 <<
" repair=" << useRePair
95 <<
" origNodes=" << origNodes
97 <<
" origEdges=" << origEdges
98 <<
" file=" << filename
99 <<
" origHeight=" << origHeight
100 <<
" origAvgDepth=" << origAvgDepth
Transform a tree into its top tree.
vector< DagNode< DataType > > nodes
static long long write(const TopDag< DataType > &dag, const Labels< DataType > &labels, const std::string &fn, const bool verbose=true)
int main(int argc, char **argv)
Ordered tree data structure.
string getDataArg(const int index) const
get a data argument by its index (among the data arguments)
bool isSet(const string &arg) const
check whether an argument was set
uint numDataArgs() const
the number of unnamed data arguments
Read an XML file into a tree, using RapidXml.
Parse command-line arguments.
void construct(DebugInfo *debugInfo=NULL)
T get(const string &key, const T defaultValue=T())
Transform a tree into its top tree.
string summary() const
A one-line summary of the tree.
int countEdges() const
Count the number of edges in the DAG.
A binary DAG that is specialised to be a top tree's minimal DAG.
void construct(DebugInfo *debugInfo=NULL, const double minRatio=1.2)
Compute size of a succinct encoding of a tree.
A key-value label storage.