![]() |
Quetzal-CoaTL
The Coalescence Template Library
|
#include <quetzal/coalescence/graph/binary_tree.hpp>
A binary tree class with information attached to vertices.
VertexProperty | The type of information to store at each vertex. |
This class can be used as a simple way to describe the kind of topology and mutational process that emerge from evolutionary relationships between a sample of sequences for a non-recombining locus. Vertices embed a user-defined type of information. Edges embed no additional information. This graph structure is bidirected and allows to model a forest of disconnected trees and isolated vertices.
Public Types | |
using | edge_descriptor = typename base::edge_descriptor |
Edge descriptor. | |
using | vertex_descriptor = typename base::vertex_descriptor |
Vertex descriptor. | |
using | degree_size_type = typename base::degree_size_type |
Degree size type. | |
using | traversal_category = typename base::traversal_category |
The ways in which the vertices in the graph can be traversed. | |
using | directed_category = typename base::directed_category |
The graph is bidirected. | |
using | in_edge_iterator = typename base::in_edge_iterator |
Iterate through the in-edges. | |
using | edge_parallel_category = typename base::edge_parallel_category |
Public Member Functions | |
Constructors | |
binary_tree () | |
Default constructor. Initializes a graph with 0 vertices. | |
binary_tree (size_t n) | |
Construct graph with \(n\) vertices. | |
Topology Modifiers | |
vertex_descriptor | add_vertex (const VertexProperty &p) |
Add a vertex and its properties to the graph. | |
std::pair< edge_descriptor, edge_descriptor > | add_edges (vertex_descriptor parent, vertex_descriptor left, vertex_descriptor right) |
Add edges between the parent vertex and the two children. | |
Property Lookup | |
const VertexProperty & | operator[] (vertex_descriptor v) const |
Read only access to the vertex property. | |
VertexProperty & | operator[] (vertex_descriptor v) |
Read and write access to the vertex property. | |
Topology Lookup | |
bool | is_isomorphic (binary_tree_common const &other) const |
Detects if there is a 1-to-1 mapping of the vertices in one graph to the vertices of another graph such that adjacency is preserved. | |
vertex_descriptor | find_root_from (vertex_descriptor u) const |
Finds the root of the tree graph starting from a vertex \(u\). | |
degree_size_type | degree (vertex_descriptor u) const |
Returns the number of in-edges plus out-edges. | |
degree_size_type | in_degree (vertex_descriptor u) const |
Returns the number of in-edges of vertex \(u\). | |
degree_size_type | out_degree (vertex_descriptor v) const |
Returns the number of out-edges of vertex \(v\). | |
bool | has_predecessor (vertex_descriptor u) const |
Evaluates if vertex \(u\) has a predecessor. | |
vertex_descriptor | predecessor (vertex_descriptor u) const |
The predecessor of vertex \(u\). | |
bool | has_successors (vertex_descriptor u) const |
Evaluates if vertex \(u\) has successors. | |
auto | successors (vertex_descriptor u) const |
The successors of vertex \(u\). | |
bool | is_left_successor (vertex_descriptor u) const |
Evaluate if vertex \(u\) is a left successor. | |
bool | is_right_successor (vertex_descriptor u) const |
Evaluate if vertex \(u\) is a right successor. | |
Iterators | |
std::pair< in_edge_iterator, in_edge_iterator > | in_edges (vertex_descriptor u) const |
Provides iterators to iterate over the in-going edges of vertex \(u\). | |
Algorithms | |
void | depth_first_search (vertex_descriptor s, DFSTreeVisitor &vis) |
Performs a read-and-write depth-first traversal of the vertices starting at vertex \(s\). | |
void | depth_first_search (vertex_descriptor s, DFSTreeVisitor &vis) const |
Performs a read-only depth-first traversal of the vertices starting at vertex \(s\). | |
Input/Output | |
void | to_graphviz (std::ostream &out) const |
Print the tree to the graphviz format. | |
Static Public Member Functions | |
static constexpr vertex_descriptor | null_vertex () |
Protected Attributes | |
base | _graph |
|
inlineinherited |
Returns the number of in-edges plus out-edges.
u | The vertex \(u\) |
|
inlineinherited |
Performs a read-and-write depth-first traversal of the vertices starting at vertex \(s\).
DFSTreeVisitor |
s | The vertex to start from. |
vis | The visitor to apply. |
|
inlineinherited |
Performs a read-only depth-first traversal of the vertices starting at vertex \(s\).
DFSTreeVisitor |
s | The vertex to start from. |
vis | The visitor to apply. |
|
inlineinherited |
Finds the root of the tree graph starting from a vertex \(u\).
u | The vertex to start from. |
|
inlineinherited |
Evaluates if vertex \(u\) has a predecessor.
u | The vertex to evaluate |
|
inlineinherited |
Evaluates if vertex \(u\) has successors.
u | The vertex to evaluate |
|
inlineinherited |
Returns the number of in-edges of vertex \(u\).
u | The vertex \(u\) |
|
inlineinherited |
Provides iterators to iterate over the in-going edges of vertex \(u\).
u | The vertex \(u\). |
|
inlineinherited |
Detects if there is a 1-to-1 mapping of the vertices in one graph to the vertices of another graph such that adjacency is preserved.
other | A binary tree graph. |
|
inlineinherited |
Evaluate if vertex \(u\) is a left successor.
u | The vertex to be evaluated |
|
inlineinherited |
Evaluate if vertex \(u\) is a right successor.
u | The vertex to be evaluated |
|
inlineinherited |
The predecessor of vertex \(u\).
u | The vertex |
|
inlineinherited |
The successors of vertex \(u\).
u | The vertex |