![]() |
Quetzal-CoaTL
The Coalescence Template Library
|
#include <quetzal/coalescence/graph/network.hpp>
A network class with information attached to edges.
EdgeProperty | The type of information to store at each edge. |
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 no additional information. Edges embed an user-defined type of information. This graph structure is bidirected and allows to model a forest of disconnected networks and isolated vertices.
Public Types | |
using | edge_descriptor = typename base::edge_descriptor |
Edge descriptor. | |
using | vertex_descriptor = typename base::vertex_descriptor |
Vertex descriptor. | |
using | vertex_property = no_property |
Vertex information. | |
using | edge_property = EdgeProperty |
Edge information. | |
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 | out_edge_iterator = typename base::out_edge_iterator |
Iterate through the out-edges. | |
using | edge_parallel_category = typename base::edge_parallel_category |
Public Member Functions | |
Constructors | |
network () | |
Default constructor. Initializses a graph with 0 vertices. | |
network (size_t n) | |
Construct graph with \(n\) vertices. | |
Property Lookup | |
const EdgeProperty & | operator[] (const edge_descriptor &edge) const |
Read only access to the edge property. | |
EdgeProperty & | operator[] (const edge_descriptor &edge) |
Read and write access to the edge property. | |
Topology Lookup | |
bool | is_isomorphic (network_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 network 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\). | |
std::optional< edge_descriptor > | edge (vertex_descriptor u, vertex_descriptor v) const |
Returns the edge between two vertices of the graph if the edge exists. | |
vertex_descriptor | source (edge_descriptor e) const |
Returns the source vertex of a directed edge. | |
vertex_descriptor | target (edge_descriptor e) const |
Returns the target vertex of a directed edge. | |
Topology Modification | |
vertex_descriptor | add_vertex () |
void | clear_vertex (vertex_descriptor u) |
Remove all edges to and from vertex \(u\) from the graph. | |
void | remove_vertex (vertex_descriptor u) |
Remove vertex u from the graph, also removing all edges to and from vertex \(u\). | |
edge_descriptor | add_edge (vertex_descriptor u, vertex_descriptor v) |
Inserts the edge \((u,v)\) into the graph if it does not exist, and returns an edge descriptor pointing to the new edge. | |
void | remove_edge (vertex_descriptor u, vertex_descriptor v) |
Remove the edge \((u,v)\) from the graph. | |
void | remove_edge (edge_descriptor e) |
Remove the edge \(e\) from the graph. | |
Iterators | |
auto | in_edges (vertex_descriptor u) const |
Provides a range to iterate over the in-going edges of vertex \(u\). | |
auto | out_edges (vertex_descriptor u) const |
Provides a range to iterate over the out-going edges of vertex \(u\). | |
auto | vertices () const |
Provides a range to iterate over the vertices of the graph. | |
Algorithms | |
void | depth_first_search (vertex_descriptor start, DFSVisitor &vis) |
Performs a read-and-write depth-first traversal of the vertices starting at vertex \(s\). | |
void | depth_first_search (vertex_descriptor start, DFSVisitor &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 graph to the graphviz format. | |
Static Public Member Functions | |
static constexpr vertex_descriptor | null_vertex () |
Null vertex identifier. | |
Protected Attributes | |
base | _graph |
|
inlineinherited |
Inserts the edge \((u,v)\) into the graph if it does not exist, and returns an edge descriptor pointing to the new edge.
u | Source vertex |
u | Target vertex |
|
inlineinherited |
Remove all edges to and from vertex \(u\) from the graph.
u | The vertex |
|
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\).
DFSVisitor |
start | 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\).
DFSVisitor |
start | The vertex to start from. |
vis | The visitor to apply. |
|
inlineinherited |
Returns the edge between two vertices of the graph if the edge exists.
u | The first vertex |
u | The second vertex |
|
inlineinherited |
Finds the root of the network 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 a range 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 network graph. |
|
inlinestaticconstexprinherited |
Null vertex identifier.
|
inlineinherited |
Provides a range to iterate over the out-going edges of vertex \(u\).
u | The vertex \(u\). |
|
inlineinherited |
The predecessor of vertex \(u\).
u | The vertex |
|
inlineinherited |
Remove the edge \(e\) from the graph.
e | The edge to remove |
|
inlineinherited |
Remove the edge \((u,v)\) from the graph.
u | Source vertex |
u | Target vertex |
|
inlineinherited |
Remove vertex u from the graph, also removing all edges to and from vertex \(u\).
u | The vertex to remove. |
|
inlineinherited |
Returns the source vertex of a directed edge.
e | The edge |
|
inlineinherited |
The successors of vertex \(u\).
u | The vertex |
|
inlineinherited |
Returns the target vertex of a directed edge.
e | The edge |
|
inlineinherited |
Provides a range to iterate over the vertices of the graph.