template<class VertexProperty, class EdgeProperty>
requires (!std::is_same_v<VertexProperty, no_property> && !std::is_same_v<EdgeProperty, no_property>)
class quetzal::coalescence::network< VertexProperty, EdgeProperty >
A network class with information attached to vertices.
- Template Parameters
-
VertexProperty | The type of information to store at each vertex. |
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 and edges embed additional information as user-defined types. This graph structure is bidirected and allows to model a forest of disconnected networks and isolated vertices.
- Invariant
- Guarantees that each vertex \(v\) has exactly \(0\) or \(n \geq 2\) successors, never \(1\).
-
Guarantees that each vertex \(v\) has exactly \(0\) or \(1\) predecessor.
-
Guarantees that if \((u,v)\) is an edge of the graph, then \((v,u)\) is also an edge.
Example
Output
|
|
| network () |
| Default constructor. Initializes a graph with 0 vertices.
|
|
| network (size_t n) |
| Construct graph with \(n\) vertices.
|
|
|
vertex_descriptor | add_vertex (const VertexProperty &p) |
| Add a vertex and its properties to the graph.
|
|
std::vector< edge_descriptor > | add_edges (vertex_descriptor parent, std::vector< std::tuple< vertex_descriptor, EdgeProperty > > children) |
| Add edges from the parent vertex (source) to the children (target)
|
|
|
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.
|
|
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.
|
|
|
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.
|
|
|
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.
|
|
|
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.
|
|
|
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\).
|
|
|
void | to_graphviz (std::ostream &out) const |
| Print the graph to the graphviz format.
|
|