26 cout <<
"Usage: " << name <<
" <options>" << endl
27 <<
" -n <int> tree size (edges) (default: 10)" << endl
28 <<
" -l <int> number of distinct labels" << endl
29 <<
" -o <str> output XML filename (default: do not write)" << endl
30 <<
" -s <int> seed (default: 12345678)" << endl
31 <<
" -d dump DOT graph if tree is small enough" << endl
32 <<
" -c construct Top DAG" << endl
33 <<
" -v verbose output" << endl;
36 int main(
int argc,
char **argv) {
39 if (argParser.
isSet(
"h") || argParser.
isSet(
"-help")) {
44 const int size = argParser.
get<
int>(
"n", 10);
45 const int seed = argParser.
get<
int>(
"s", 12345678);
46 const int numLabels = argParser.
get<
int>(
"l", 2);
47 const std::string outfn = argParser.
get<std::string>(
"o",
"");
48 const bool dump = argParser.
isSet(
"d");
49 const bool construct = argParser.
isSet(
"c");
50 const bool verbose = argParser.
isSet(
"v");
62 if (verbose) cout <<
"Generated " << tree.
summary() <<
" in " << timer.
get() <<
"ms" << endl;
72 if (size <= 30) cout << tree << endl;
76 cout <<
"Wrote DOT file in " << timer.
getAndReset() <<
"ms" << endl;
81 cout <<
"Graphed DOT file in " << timer.
getAndReset() <<
"ms" << endl;
96 if (verbose) cout <<
"Top DAG construction took " << timer.
get() <<
"ms" << endl;
100 const double percentage = (edges * 100.0) / treeEdges;
101 const double ratio = ((int)(1000 / percentage)) / 10.0;
103 cout <<
"Top dag has " << dag.
nodes.size() - 1 <<
" nodes, " << edges <<
" edges (" << percentage
104 <<
"% of original tree, " << ratio <<
":1)" << endl;
109 if (verbose) cout <<
"Wrote DOT file in " << timer.
get() <<
"ms" << endl;
115 if (verbose) cout <<
"Graphed DOT file in " << timer.
get() <<
"ms" << endl;
Export a tree as a DOT graph.
vector< DagNode< DataType > > nodes
int main(int argc, char **argv)
Ordered tree data structure.
bool isSet(const string &arg) const
check whether an argument was set
Export a Top DAG as a DOT graph.
Parse command-line arguments.
std::mt19937 & getRandomGenerator()
shared random generator
void construct(DebugInfo *debugInfo=NULL)
T get(const string &key, const T defaultValue=T())
Generates ordered unlabelled trees uniformly at random.
Transform a tree into its top tree.
string summary() const
A one-line summary of the tree.
Base class for exporting various graphs (or trees) as DOT files.
XML tree writer (empty template for overloading)
int countEdges() const
Count the number of edges in the DAG.
static void drawSvg(const string &dotfile, const string &outfilename)
A binary DAG that is specialised to be a top tree's minimal DAG.
void generateTree(TreeType &tree, const int numEdges, const bool verbose=false)