|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_TREE_TREE_H_
2 #define GENESIS_TREE_TREE_H_
196 return links_.empty() && nodes_.empty() && edges_.empty();
204 assert( index < links_.size() );
205 return *links_[ index ].get();
213 assert( index < links_.size() );
214 return *links_[ index ].get();
222 assert( index < nodes_.size() );
223 return *nodes_[ index ].get();
231 assert( index < nodes_.size() );
232 return *nodes_[ index ].get();
240 assert( index < edges_.size() );
241 return *edges_[ index ].get();
249 assert( index < edges_.size() );
250 return *edges_[ index ].get();
258 return links_.size();
266 return nodes_.size();
274 return edges_.size();
302 return root_link_->
node();
310 return root_link_->
node();
366 return links_.begin();
371 return links_.cbegin();
381 return links_.cend();
400 return nodes_.begin();
405 return nodes_.cbegin();
415 return nodes_.cend();
434 return edges_.begin();
439 return edges_.cbegin();
449 return edges_.cend();
490 #endif // include guard
IteratorLinks end_links()
size_t node_count() const
Return the number of TreeNodes of the Tree.
std::vector< std::unique_ptr< T > > ContainerType
Alias for the container type that is used to store TreeLinks, TreeNodes and TreeEdges.
IteratorLinks begin_links()
size_t link_count() const
Return the number of TreeLinks of the Tree.
ConstIteratorLinks end_links() const
TreeNode & node()
Return the TreeNode of this TreeLink.
LinkContainerType & expose_link_container()
Get the container that stores all TreeLinks of the Tree.
IteratorEdges end_edges()
NodeContainerType & expose_node_container()
Get the container that stores all TreeNodes of the Tree.
TreeNode & node_at(size_t index)
Return the TreeNode at a certain index.
TreeEdge & edge_at(size_t index)
Return the TreeEdge at a certain index.
Iterator class that exposes elements in a container of pointers.
utils::Range< ConstIteratorEdges > edges() const
TreeNode & root_node()
Return the TreeNode at the current root of the Tree.
TreeNode const & node_at(size_t index) const
Return the TreeNode at a certain index.
ConstIteratorNodes end_nodes() const
utils::Range< ConstIteratorLinks > links() const
IteratorEdges begin_edges()
Class for representing phylogenetic trees.
Tree & reset_root_link(TreeLink *root_link)
Reset the link that is considered to be the root of the Tree.
ConstIteratorEdges begin_edges() const
utils::Range< IteratorLinks > links()
TreeNode const & root_node() const
Return the TreeNode at the current root of the Tree.
IteratorNodes begin_nodes()
friend bool validate_topology(Tree const &tree)
Validate the correctness of all Tree pointers etc.
bool empty() const
Return whether the Tree is empty (i.e., has no nodes, edges and links).
TreeLink & root_link()
Return the TreeLink at the current root of the Tree.
void clear()
Deletes all data of the tree, including all links, nodes and edges.
ContainerType< TreeLink > LinkContainerType
Alias for the container type that is used to store TreeLinks.
void swap(Tree &other)
Swap.
EdgeContainerType & expose_edge_container()
Get the container that stores all TreeEdges of the Tree.
TreeLink const & link_at(size_t index) const
Return the TreeLink at a certain index.
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops.
utils::Range< ConstIteratorNodes > nodes() const
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
utils::Range< IteratorNodes > nodes()
Tree & operator=(Tree const &other)
Assignment operator.
utils::Range< IteratorEdges > edges()
Tree clone_topology() const
Return a Tree with the same topology, but without any data.
ContainerType< TreeEdge > EdgeContainerType
Alias for the container type that is used to store TreeEdges.
ContainerType< TreeNode > NodeContainerType
Alias for the container type that is used to store TreeNodes.
TreeLink & link_at(size_t index)
Return the TreeLink at a certain index.
TreeEdge const & edge_at(size_t index) const
Return the TreeEdge at a certain index.
ConstIteratorNodes begin_nodes() const
IteratorNodes end_nodes()
ConstIteratorLinks begin_links() const
bool validate_topology(Tree const &tree)
Validate that all internal pointers of the Tree elements (TreeLinks, TreeNodes, TreeEdges) to each ot...
size_t edge_count() const
Return the number of TreeEdges of the Tree.
ConstIteratorEdges end_edges() const
TreeLink const & root_link() const
Return the TreeLink at the current root of the Tree.