#include <genesis/tree/printer/compact.hpp>
Print a Tree in a compact form, i.e., each node and edge on one line.
For example, given the Newick tree
(((A:0.2,B:0.3)C:0.3,(D:0.4,E:0.45,F:0.3,G:0.35)H:0.25)I:0.8,J:0.4,K:0.5)L;
and using the print( Tree const& ) function for CommonTrees, the output is
L: 0.8 ├── I: 0.8 │ ├── C: 0.3 │ │ ├── A: 0.2 │ │ └── B: 0.3 │ └── H: 0.25 │ ├── D: 0.4 │ ├── E: 0.45 │ ├── F: 0.3 │ └── G: 0.35 ├── J: 0.4 └── K: 0.5
Using the print() functions with function parameters, it is also possible to print custom data for each node and edge.
Definition at line 82 of file compact.hpp.
Public Member Functions | |
PrinterCompact ()=default | |
Default constructor. More... | |
PrinterCompact (PrinterCompact &&)=default | |
Default move constructor. More... | |
PrinterCompact (PrinterCompact const &)=default | |
Default copy constructor. More... | |
~PrinterCompact ()=default | |
Default destructor. More... | |
long | limit () const |
Get the current line limit. More... | |
PrinterCompact & | limit (long value) |
Set the line limit. More... | |
PrinterCompact & | operator= (PrinterCompact &&)=default |
Default move assignment. More... | |
PrinterCompact & | operator= (PrinterCompact const &)=default |
Deault copy assignment. More... | |
void | print (std::ostream &out, Tree const &tree, std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const print_line) |
Print a compact representation of a Tree to an output stream, using a given function for output of the Node and Edge data. More... | |
std::string | print (Tree const &tree) |
Print a compact representation of a Tree to a std::string , for CommonTrees. More... | |
std::string | print (Tree const &tree, std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const print_line) |
Print a compact representation of a Tree to a std::string , using a given function for output of the Node and Edge data. More... | |
|
default |
Default constructor.
|
default |
Default destructor.
|
default |
Default copy constructor.
|
default |
Default move constructor.
|
inline |
Get the current line limit.
See limit( long ) for details.
Definition at line 196 of file compact.hpp.
|
inline |
Set the line limit.
If set to a negative value, the full tree is printed. For any value greater than 0, only this many lines are printed, following a preorder traversal of the tree. If the tree contains more nodes than being printed, an additional line with ellipsis is printed, to indicate this fact.
Definition at line 185 of file compact.hpp.
|
default |
Default move assignment.
|
default |
Deault copy assignment.
void print | ( | std::ostream & | out, |
Tree const & | tree, | ||
std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const | print_line | ||
) |
Print a compact representation of a Tree to an output stream, using a given function for output of the Node and Edge data.
The print_line
function parameter is used to customize the output per printed line: The function takes the current TreeNode and TreeEdge, and returns the desired string representation for that line. See the implementation of print( Tree const& ) for an example.
Definition at line 50 of file compact.cpp.
std::string print | ( | Tree const & | tree | ) |
Print a compact representation of a Tree to a std::string
, for CommonTrees.
The function casts the node and edge data to CommonNodeData and CommonEdgeData, and, if successfull, prints the node name and branch length for each line.
If the data is not actually default data, the nodes are printed without any text, i.e., only the topology of the Tree via lines is shown.
Definition at line 161 of file compact.cpp.
std::string print | ( | Tree const & | tree, |
std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const | print_line | ||
) |
Print a compact representation of a Tree to a std::string
, using a given function for output of the Node and Edge data.
See print() for details on the print_line
function parameter.
Definition at line 149 of file compact.cpp.