A library for working with phylogenetic and population genetic data.
v0.27.0
tree/function/manipulation.hpp File Reference
#include <cstddef>
#include <functional>
#include "genesis/tree/tree.hpp"
#include "genesis/tree/common_tree/tree.hpp"

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::tree
 

Enumerations

enum  LadderizeOrder { kSmallFirst, kLargeFirst }
 

Functions

TreeNode & add_new_leaf_node (Tree &tree, TreeEdge &target_edge, std::function< void(TreeEdge &target_edge, TreeEdge &new_edge)> adjust_edges={})
 Add a new Node as a leaf to an existing Edge, by also adding a new Node in the middle of that Edge. More...
 
TreeNode & add_new_node (Tree &tree, TreeEdge &target_edge, std::function< void(TreeEdge &target_edge, TreeEdge &new_edge)> adjust_edges={})
 Add a new Node that splits an existing Edge. More...
 
TreeNode & add_new_node (Tree &tree, TreeNode &target_node)
 Add a new Node as a leaf to an existing Node. More...
 
void change_rooting (Tree &tree, TreeLink &at_link)
 "Reroot" the Tree at the given TreeLink. More...
 
void change_rooting (Tree &tree, TreeNode &at_node)
 Reroot the Tree at the given TreeNode. More...
 
void delete_edge (Tree &tree, TreeEdge &target_edge, std::function< void(TreeNode &remaining_node, TreeNode &deleted_node)> adjust_nodes={})
 Delete a TreeEdge from a Tree, that is, contract the two TreeNodes at its ends into one TreeNode. More...
 
void delete_leaf_node (Tree &tree, TreeNode &target_node)
 Delete a leaf TreeNode. More...
 
void delete_linear_node (Tree &tree, TreeNode &target_node, std::function< void(TreeEdge &remaining_edge, TreeEdge &deleted_edge)> adjust_edges={})
 Delete a "linear" TreeNode from a Tree, that is, a node with two neighbours. More...
 
void delete_node (Tree &tree, TreeNode &target_node)
 Delete a TreeNode from a Tree. More...
 
void delete_subtree (Tree &tree, Subtree const &subtree)
 Delete a complete Subtree from a Tree. More...
 
void delete_zero_branch_length_edges (Tree &tree, bool include_leaf_edges=false)
 Delete (contract) all branches of a CommonTree that have branch length zero. More...
 
void ladderize (Tree &tree, LadderizeOrder order=LadderizeOrder::kSmallFirst)
 Ladderize a Tree, that is, order its subtrees by size. More...
 
TreeNode & make_rooted (Tree &tree, std::function< void(TreeEdge &target_edge, TreeEdge &new_edge)> adjust_edges={})
 Root a Tree on the first TreeEdge of its current top level TreeNode. More...
 
TreeNode & make_rooted (Tree &tree, TreeEdge &target_edge, std::function< void(TreeEdge &target_edge, TreeEdge &new_edge)> adjust_edges={})
 Root a Tree at a given TreeEdge. More...
 
void make_unrooted (Tree &tree, std::function< void(TreeEdge &remaining_edge, TreeEdge &deleted_edge)> adjust_edges={})
 Unroot a Tree. More...
 
template<class NodeDataType = CommonNodeData, class EdgeDataType = CommonEdgeData>
Tree minimal_tree ()
 Create a minimal Tree that can be used with manipulation functions such as add_new_node() or add_new_leaf_node() to build a custom tree, including default data types at nodees and edges. More...
 
Tree minimal_tree_topology ()
 Create a minimal Tree that can be used with manipulation functions such as add_new_node() or add_new_leaf_node() to build a custom tree. More...