string write_no_names(const_branchview b, bool print_lengths) { string output; // If this is a leaf node, then print the name if (b.target().is_leaf_node()) output += convertToString(b.target().name()+1); // If this is an internal node, then print the subtrees else { vector<const_branchview> branches = sorted_branches_after(b); output = "("; for(int i=0;i<branches.size();i++) { output += write_no_names(branches[i],print_lengths); if (i+1<branches.size()) output += ","; } output += ")"; } // print the branch length if requested if (print_lengths) output += ":" + convertToString(b.length()); return output; }
string write_with_bootstrap_fraction(const vector<string>& names, const_branchview b, const vector<double>& bf, bool print_lengths) { string output; // If this is a leaf node, then print the name if (b.target().is_leaf_node()) output += names[b.target()]; // If this is an internal node, then print the subtrees else { vector<const_branchview> branches = sorted_branches_after(b); output = "("; for(int i=0;i<branches.size();i++) { output += write_with_bootstrap_fraction(names,branches[i],bf,print_lengths); if (i+1<branches.size()) output += ","; } output += ")"; } // print the branch length if requested double bfb = bf[b.undirected_name()]; if (bfb >= 0) output += " " + convertToString<double>(bf[b.undirected_name()]); if (print_lengths) output += ":" + convertToString(b.length()); else if (bfb >= 0) output += ":1.0"; return output; }
bool branch_order(const const_branchview& b1,const const_branchview& b2) { return b1.target().name() < b2.target().name(); }