LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
|
Free tree graph class. More...
#include <free_tree.hpp>
Public Member Functions | |
free_tree () noexcept | |
Empty constructor. | |
free_tree (const uint64_t n) noexcept | |
Constructor with number of vertices. | |
free_tree (const free_tree &t) noexcept | |
Copy constructor. | |
free_tree (free_tree &&t) noexcept | |
Move constructor. | |
free_tree (const undirected_graph &t) noexcept | |
Copy constructor with undirected graph. | |
free_tree (undirected_graph &&t) noexcept | |
Move constructor with undirected graph. | |
~free_tree () noexcept | |
Destructor. | |
free_tree & | operator= (const free_tree &f) noexcept |
Copy assignment operator. | |
free_tree & | operator= (free_tree &&f) noexcept |
Copy assignment operator. | |
free_tree & | add_node () noexcept |
Adds a vertex to the graph. | |
free_tree & | remove_node (const node u, const bool norm=true, const bool check_norm=true) noexcept |
Remove a node from this graph. | |
free_tree & | add_edge (const node s, const node t, const bool norm=true, const bool check_norm=true) noexcept |
Adds an edge to the tree. | |
free_tree & | add_edge_bulk (const node s, const node t) noexcept |
Adds an edge to the tree. | |
void | finish_bulk_add (const bool norm=true, const bool check=true) noexcept |
Finishes adding edges in bulk. | |
void | finish_bulk_add_complete (const bool norm=true, const bool check=true) noexcept |
Completes the inner structure of the tree after adding edges in bulk. | |
free_tree & | add_edges (const std::vector< edge > &edges, const bool norm=true, const bool check_norm=true) noexcept |
Adds a list of edges to the graph. | |
free_tree & | set_edges (const std::vector< edge > &edges, const bool norm=true, const bool check_norm=true) noexcept |
Sets the edges to the graph. | |
free_tree & | remove_edge (const node s, const node t, const bool norm=false, const bool check_norm=true) noexcept |
Remove an edge from this graph. | |
free_tree & | remove_edge_bulk (const node s, const node t) noexcept |
Removes an edge from the tree. | |
void | finish_bulk_remove (const bool norm=true, const bool check=true) noexcept |
Finishes removing edges in bulk. | |
void | finish_bulk_remove_complete (const bool norm=true, const bool check=true) noexcept |
Completes the inner structure of the tree after removing edges in bulk. | |
free_tree & | remove_edges (const std::vector< edge > &edges, const bool norm=true, const bool check_norm=true) noexcept |
Remove an edge from this graph. | |
free_tree & | remove_edges_incident_to (const node u, const bool norm=true, const bool check_norm=true) noexcept |
Remove all edges incident to a given vertex. | |
free_tree & | disjoint_union (const free_tree &t) noexcept |
Disjoint union of trees. | |
void | calculate_tree_type () noexcept |
Calculates the type of tree. | |
bool | is_rooted () const noexcept |
Returns whether this tree is a rooted tree. | |
head_vector | get_head_vector (const node r=0, const linear_arrangement &arr={}) const noexcept |
Converts a free tree into a head vector. | |
void | reserve_degree (const node u, const uint64_t d) noexcept |
Predicts that the degree of node u is d. | |
std::vector< edge_pair > | get_Q () const noexcept |
Returns all independent pairs of edges of this graph. | |
std::vector< edge > | get_edges () const noexcept |
Returns all edges of this graph. | |
const neighbourhood & | get_neighbors (const node u) const noexcept |
Returns the neighbourhood of node u. | |
uint64_t | get_degree (const node u) const noexcept |
Returns the number of neighbors of u. | |
bool | has_edge (const node u, const node v) const noexcept |
Returns true if the edge \(\{u,v\}\) exists in the graph. | |
bool | is_directed () const noexcept |
Returns whether this graph is directed or not. | |
bool | is_undirected () const noexcept |
Returns whether this graph is undirected or not. | |
std::vector< undirected_graph > | get_connected_components () const noexcept |
Returns all the connected components of this graph as individual graphs. | |
bool | is_tree () const noexcept |
Is this graph an actual tree? | |
virtual bool | can_add_edge (node const s, const node t) const noexcept |
Can this edge be added? | |
virtual bool | can_add_edges (const std::vector< edge > &edges) const noexcept |
Can these edges be added? | |
uint64_t | get_component_representative (const node u) const noexcept |
Representative node of the connected component in which u belongs. | |
bool | are_nodes_in_same_component (const node u, const node v) const noexcept |
Checks if two nodes are in the same connected component. | |
uint64_t | get_num_nodes_component (const node u) const noexcept |
Amount of nodes in a connected component of the tree. | |
bool | is_of_tree_type (const tree_type &tt) const noexcept |
Returns whether this tree is of type tt. | |
bool | is_tree_type_valid () const noexcept |
Is the type of this tree valid? | |
std::vector< std::string > | get_tree_type_list () const noexcept |
Returns the list of types as a list of strings. | |
virtual void | init (const uint64_t n) noexcept |
Allocates the necessary memory for this class. | |
virtual void | clear () noexcept |
Frees the memory occupied by this graph. | |
virtual void | normalize () noexcept |
Normalizes the graph. | |
virtual bool | check_normalized () noexcept |
Checks if the graph is normalized. | |
void | set_normalized (const bool v=true) noexcept |
Sets whether this graph is normalized or not. | |
bool | has_node (const node u) const noexcept |
Returns true if node u is in this graph. | |
uint64_t | get_num_nodes () const noexcept |
Returns the number of ndoes. | |
uint64_t | get_num_edges () const noexcept |
Returns the number of edges. | |
bool | is_normalized () const noexcept |
Returns whether this graph is normalized or not. | |
Protected Member Functions | |
void | _init (const uint64_t n) noexcept |
Initializes the memory in the graph hierarchy. | |
void | _clear () noexcept |
Clears the memory in the graph hierarchy. | |
void | actions_after_add_edge (const node u, const node v) noexcept |
Do some extra work after the addition of an edge. | |
void | actions_after_add_edges (const edge_list &e) noexcept |
Do some extra work after the addition of several edges. | |
void | actions_after_add_edges_bulk () noexcept |
Do some extra work after the addition of several edges in bulk. | |
void | actions_after_remove_edge (const node u, const node v) noexcept |
Do some extra work after the removal of an edge. | |
void | actions_after_remove_edges (const edge_list &e) noexcept |
Do some extra work after the removal of several edges. | |
void | actions_after_remove_edges_bulk () noexcept |
Do some extra work after the removal of several edges in bulk. | |
void | actions_after_remove_node (const node u) noexcept |
Do some work before the removal of a vertex. | |
void | actions_before_remove_edges_incident_to (const node u) noexcept |
Do some work before all edges incident to a node is removed. | |
void | update_union_find_after_add_edge (const node u, const node v, uint64_t *const root_of, uint64_t *const root_size) const noexcept |
Update the union find data structure after an edge addition. | |
void | update_union_find_after_add_edges (const edge_list &edges, uint64_t *const root_of, uint64_t *const root_size) const noexcept |
Update the union find data structure after the addition of a set of edges. | |
void | update_union_find_after_add_edges_bulk (uint64_t *const root_of, uint64_t *const root_size) const noexcept |
Update the union find data structure after the addition of several edges. | |
void | update_union_find_after_remove_edge (const node u, const node v, uint64_t *const root_of, uint64_t *const root_size) const noexcept |
Update the union find data structure after an edge removal. | |
void | update_union_find_after_remove_edges (const edge_list &edges, uint64_t *const root_of, uint64_t *const root_size) const noexcept |
Update the union find data structure after the removal of a set of edges. | |
void | update_union_find_after_remove_edges_bulk (uint64_t *const root_of, uint64_t *const root_size) const noexcept |
Update the union find data structure after the removal of several edges. | |
void | update_union_find_before_remove_incident_edges_to (const node u, uint64_t *const root_of, uint64_t *const root_size) const noexcept |
Update the union find data structure before the removal of all edges incident to a node. | |
void | copy_full_free_tree (const free_tree &f) noexcept |
Copies all members of this class and the parent classes. | |
void | move_full_free_tree (free_tree &&f) noexcept |
Moves all members of this class and the parent classes. | |
void | copy_full_undirected_graph (const undirected_graph &u) noexcept |
Copies all members of this class and the parent class. | |
void | move_full_undirected_graph (undirected_graph &&u) noexcept |
Moves all members of this class and the parent class. | |
void | tree_only_init (const uint64_t n) noexcept |
Initializes only the memory of class tree. | |
void | tree_only_clear () noexcept |
Clears the memory used by only class tree. | |
void | tree_only_copy (const tree &t) noexcept |
Copies only members of class tree. | |
void | tree_only_move (tree &&t) noexcept |
Moves only members of class tree. | |
void | tree_only_add_node () noexcept |
Adds a node to this tree. | |
void | tree_only_invalidate () noexcept |
Invalidates the aggregated information of the tree. | |
void | tree_only_actions_after_add_edge (const node u, const node v) noexcept |
Do some work after the addition of an edge. | |
void | tree_only_actions_after_add_edges (const edge_list &e) noexcept |
Do some work after the addition of several edges. | |
void | tree_only_actions_after_add_edges_bulk () noexcept |
Do some work after the addition of several edges in bulk. | |
void | tree_only_actions_after_add_edges_bulk_complete () noexcept |
Do some work after the addition of several edges in bulk. | |
void | tree_only_actions_after_remove_edges_bulk () noexcept |
Do some work after the removal of several edges in bulk. | |
void | tree_only_actions_after_remove_edges_bulk_complete () noexcept |
Do some work after the removal of several edges in bulk. | |
void | tree_only_actions_after_remove_edge (const node u, const node v) noexcept |
Do some work after the removal of an edge. | |
void | tree_only_actions_after_remove_edges (const edge_list &e) noexcept |
Do some work after the removal of several edges. | |
void | tree_only_actions_after_remove_node (const node u) noexcept |
Do some work before the removal of a vertex. | |
void | tree_only_actions_before_remove_edges_incident_to (const node u) noexcept |
Do some work before the removal of all edges incident to a vertex. | |
void | tree_only_set_edges () noexcept |
Updates the data structures of a tree after the graph structure has had its set of edges set. | |
void | tree_only_remove_node (const node u) noexcept |
Removes a vertex from the union-find data structure. | |
void | fill_union_find () noexcept |
void | empty_union_find () noexcept |
Empties the Union-Find data structure assuming that the tree has no edges. | |
void | copy_full_graph (const graph &g) noexcept |
Copies all members of this class. | |
void | move_full_graph (graph &&g) noexcept |
Moves all members of this class. | |
void | __add_node () noexcept |
Adds a node to the graph. | |
void | __disjoint_union (const graph &g) noexcept |
Disjoint union of graphs. | |
void | normalize_after_edge_addition (const bool norm, const bool check) noexcept |
Normalize the graph after one (or more) edges have been added. | |
void | normalize_after_edge_removal (const bool norm, const bool check) noexcept |
Normalize the graph after one (or more) edges have been removed. | |
Protected Attributes | |
std::vector< node > | m_union_find__root_of |
The root of every vertex in the union-find data structure. | |
std::vector< uint64_t > | m_union_find__root_size |
The size of the connected component that a root belongs to. | |
std::array< bool, __tree_type_size > | m_tree_type |
The type of this tree. | |
bool | m_is_tree_type_valid = false |
Is the type of this tree valid? | |
std::vector< neighbourhood > | m_adjacency_list |
Data structure that implements the graph. | |
uint64_t | m_num_edges = 0 |
Amount of edges of this graph. | |
bool | m_is_normalized = true |
Is this graph normalized? | |
Private Member Functions | |
undirected_graph & | disjoint_union (const undirected_graph &g) noexcept |
Disjoint union of graphs. | |
void | remove_single_edge (const node u, const node v, neighbourhood &out_u, neighbourhood &in_v) noexcept |
Removes a single edge. | |
Friends | |
class | rooted_tree |
Free tree graph class.
This class constrains the addition of edges so that the resulting graphs does not contain cycles. Furthermore, the edges added are undirected.
For another type of tree-like graphs, see lal::graphs::rooted_tree.
|
inlinenoexcept |
Constructor with number of vertices.
n | Number of vertices |
|
inlinenoexcept |
Copy constructor.
t | Free tree. |
|
inlinenoexcept |
Move constructor.
t | Free tree. |
|
noexcept |
Copy constructor with undirected graph.
t | An undirected graph. |
|
noexcept |
Move constructor with undirected graph.
t | An undirected graph. |
|
protectednoexceptinherited |
Disjoint union of graphs.
Given a graph, append it to the current graph.
All the nodes in g are relabelled starting at n, the number of nodes of the current graph.
g | Input graph. |
|
inlineprotectedvirtualnoexcept |
Clears the memory in the graph hierarchy.
Clears the memory of lal::graphs::free_tree, lal::graphs::undirected_graph and lal::graphs::graph classes.
Reimplemented from lal::graphs::undirected_graph.
|
inlineprotectedvirtualnoexcept |
Initializes the memory in the graph hierarchy.
Initializes memory of lal::graphs::free_tree, lal::graphs::undirected_graph and lal::graphs::graph classes.
n | Number of nodes. |
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the addition of an edge.
u | Node of the edge |
v | Node of the edge |
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the addition of several edges.
e | List of edges. |
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the addition of several edges in bulk.
This method should only be called after several calls to undirected_graph::add_edge_bulk or directed_graph::add_edge_bulk.
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the removal of an edge.
u | Node of the edge |
v | Node of the edge |
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the removal of several edges.
e | List of edges. |
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some extra work after the removal of several edges in bulk.
This method should only be called after several calls to undirected_graph::remove_edge_bulk or directed_graph::remove_edge_bulk.
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some work before the removal of a vertex.
u | Node to be removed. |
Reimplemented from lal::graphs::undirected_graph.
|
protectedvirtualnoexcept |
Do some work before all edges incident to a node is removed.
u | Node whose incident edges are to be removed. |
Reimplemented from lal::graphs::undirected_graph.
|
virtualnoexcept |
Adds an edge to the tree.
This operation checks that the edge added does not produce cycles only in a debug compilation of the library. For a more controlled addition of the edges, see can_add_edge.
For developers: method lal::graphs::graph::actions_after_add_edge is called after the edge has been added.
s | Valid node index: \(0 \le s < n\). |
t | Valid node index: \(0 \le t < n\). |
norm | Should the graph be normalized? |
check_norm | If norm is false then, should we check whether the result is normalized or not? This might be useful in case the resulting graph is normalized. If norm is true then check_norm is ignored. |
Reimplemented from lal::graphs::undirected_graph.
Adds an edge to the tree.
This method only adds an edge, and does no other work: normalisation is not checked, and no extra work per edge is done.
s | Valid node index: \(0 \le s < n\). |
t | Valid node index: \(0 \le t < n\). |
|
virtualnoexcept |
Adds a list of edges to the graph.
This function checks that edges will not produce cycles only in a debug compilation of the library. Moreover, this operation is faster than calling add_edge since the edges are added in bulk. For a more controlled addition of the edges, see can_add_edges.
edges | The edges to be added. |
norm | Normalize the graph after the insertions. |
check_norm | If norm is false then, should we check whether the result is normalized or not? This might be useful in case the resulting graph is normalized. If norm is true then check_norm is ignored. |
Reimplemented from lal::graphs::undirected_graph.
|
inlinenodiscardnoexceptinherited |
Checks if two nodes are in the same connected component.
u | First node. |
v | Second node. |
|
virtualnoexcept |
Calculates the type of tree.
See tree_type for the list of different tree types.
Implements lal::graphs::tree.
|
nodiscardvirtualnoexceptinherited |
Can this edge be added?
In a tree, an edge can only be added if it does not produce cycles, and it has not been added before.
In a rooted tree, an edge can only be added if the in-degree of vertex t (see directed_graph::get_in_degree) is exactly 1 after adding the edge.
s | First node of the edge. |
t | Second node of the edge. |
Reimplemented in lal::graphs::rooted_tree.
|
nodiscardvirtualnoexceptinherited |
Can these edges be added?
In a tree, a set of edges can only be added if their addition to the tree do not produce cycles and none of them have been added before.
In a rooted tree, edges \((s,t)\) can only be added if the in-degree of vertex t (see directed_graph::get_in_degree) is exactly 1 after adding the edge.
edges | List of edges. |
Reimplemented in lal::graphs::rooted_tree.
|
virtualnoexceptinherited |
Checks if the graph is normalized.
Checks, whether the graph's adjacency structure is normalized or not. In case it is, attribute m_is_normalized is set to true, so method is_normalized evaluates to true.
Reimplemented in lal::graphs::directed_graph.
|
virtualnoexceptinherited |
Frees the memory occupied by this graph.
See _clear for details.
Disjoint union of trees.
Given a free tree, append it to the current tree. If the current is empty (i.e., size 0), then the new tree is simply copied into the new one.
If the current tree is not empty, all the new nodes in t (appended to the current tree) are relabelled starting at n, the number of nodes of the current tree.
t | Input tree. |
|
privatenoexcept |
Disjoint union of graphs.
Given a graph, append it to the current graph.
All the nodes in g are relabelled starting at n, the number of nodes of the current graph.
g | Input graph. |
|
inlineprotectednoexceptinherited |
Fills the Union-Find data structure assuming that the graph structure has all of its edges.
|
virtualnoexcept |
Finishes adding edges in bulk.
This method updates the Union-Find data structure and all the necessary members after several calls to add_edge_bulk.
norm | Normalize the tree. |
check | Check whether the tree is normalized or not. |
Implements lal::graphs::graph.
|
virtualnoexcept |
Completes the inner structure of the tree after adding edges in bulk.
This is meant to be used after several calls to undirected_graph::add_edge_bulk, directed_graph::add_edge_bulk.
This method completes the Union-Find data structure and the other necessary members assuming that the tree is now complete.
norm | Normalize the graph. |
check | Check wether the graph is normalized or not. |
Implements lal::graphs::tree.
|
virtualnoexcept |
Finishes removing edges in bulk.
This method updates the Union-Find data structure and all the necessary members after several calls to remove_edge_bulk.
norm | Normalize the tree. |
check | Check whether the tree is normalized or not. |
Implements lal::graphs::graph.
|
virtualnoexcept |
Completes the inner structure of the tree after removing edges in bulk.
This is meant to be used after several calls to undirected_graph::remove_edge_bulk, directed_graph::remove_edge_bulk.
This method completes the Union-Find data structure and the other necessary members assuming that the tree is now empty.
norm | Normalize the graph. |
check | Check wether the graph is normalized or not. |
Implements lal::graphs::tree.
|
inlinenodiscardnoexceptinherited |
Representative node of the connected component in which u belongs.
If the current graph lacks some edges then it is clearly a forest, i.e., a series of disconnected components. This function returns a representative node of the connected component to which node u belongs.
Further, let \(cc(u)\) be the connected component of vertex u, and \(rep(cc(u))\) be the representative node of \(cc(u)\). For every other node \(v\in cc(u)\), this function will return the same representative node \(rep(cc(u))\). Therefore, \(rep(cc(u))=rep(cc(v))\) for every \(v\in cc(u)\).
u | Input node. |
|
inlinenodiscardnoexceptinherited |
Returns the number of neighbors of u.
u | Node to be queried. |
|
nodiscardnoexcept |
Converts a free tree into a head vector.
See Head vector page for a definition of 'head vector'.
r | A fictional root to be used to calculate the head vector. |
arr | Linear arrangement of the tree. |
|
inlinenodiscardnoexceptinherited |
Returns the neighbourhood of node u.
u | Node. |
|
inlinenodiscardnoexceptinherited |
Amount of nodes in a connected component of the tree.
If the current graph lacks some edges then it is clearly a forest, i.e., a series of disconnected components. This function returns the size of the component node u belongs to.
In rooted trees one has to see this amount as the number of nodes of the component in the underlying undirected forest.
u | Input node. |
|
nodiscardvirtualnoexceptinherited |
Returns all independent pairs of edges of this graph.
The set \(Q(G)\) is defined as the pairs of edges of \(G\), \(E(G) \times E(G)\), that are independent, that is, that share no nodes.
Implements lal::graphs::graph.
|
nodiscardnoexceptinherited |
Returns the list of types as a list of strings.
|
virtualnoexceptinherited |
|
inlinenodiscardnoexceptinherited |
Returns whether this graph is normalized or not.
A graph is normalized if every node's adjacency list is sorted increasingly. For this, use method normalize().
|
inlinenodiscardnoexceptinherited |
Returns whether this tree is of type tt.
See method calculate_tree_type to know how to calculate a tree's type.
tt | Type of tree (see graphs::tree_type). |
|
inlinenodiscardnoexceptinherited |
Is this graph an actual tree?
Returns true if the number of edges is one less than the number of nodes.
Note that this would not really be true if the addition of edges was not constrained. That is, since it is constrained (behind the scenes) in a way that no cycles can be produced (for example, see free_tree::add_edge, or free_tree::add_edges), then we only need to check for the number of edges.
For further characterisations of a tree see [29] (chapter 4, pages 32-33).
|
inlinenodiscardnoexceptinherited |
Is the type of this tree valid?
This function enables users determine when this tree's type should be calculated.
In case this function returns false, users should call function calculate_tree_type in order to obtain a valid tree type. Note, however, that prior to calling the function the type of this tree might be graphs::tree_type::unknown and that the tree type may remain graphs::tree_type::unknown even after the type has been calculated. Nevertheless, users should be suspicious of a tree being of graphs::tree_type::unknown (in fact, of any) type if this method returns false, yet they should be sure of it if the type was calculated via method calculate_tree_type.
|
virtualnoexceptinherited |
Normalizes the graph.
Sorts this graph's adjacency list structure in increasing order.
Besides expensive, this method may be unnecessary. Method check_normalized() checks whether the graph is normalized or not; in case it is, using this method is completely unnecessary.
Reimplemented in lal::graphs::directed_graph.
Copy assignment operator.
f | A lal::graphs::free_tree. |
Copy assignment operator.
f | A lal::graphs::free_tree. |
|
virtualnoexcept |
Remove an edge from this graph.
Method lal::graphs::graph::actions_after_remove_edge is called after the edge has been removed.
s | Valid node index: \(0 \le s < n\). |
t | Valid node index: \(0 \le t < n\). |
norm | Normalize the graph after the deletion. |
check_norm | If norm is false then, should we check whether the result is normalized or not? This might be useful in case the resulting graph is normalized. If norm is true then check_norm is ignored. |
Reimplemented from lal::graphs::undirected_graph.
Removes an edge from the tree.
This method only removes an edge, and does no other work: normalisation is not checked, and no extra work per edge is done.
s | Valid node index: \(0 \le s < n\). |
t | Valid node index: \(0 \le t < n\). |
Reimplemented from lal::graphs::undirected_graph.
|
virtualnoexcept |
Remove an edge from this graph.
This operation is faster than removing edges one by one with remove_edge(node,node,bool,bool) since the edges are removed in bulk.
edges | The edges to be deleted. |
norm | Normalize the graph after the deletion. |
check_norm | If norm is false then, should we check whether the result is normalized or not? This might be useful in case the resulting graph is normalized. If norm is true then check_norm is ignored. |
Reimplemented from lal::graphs::undirected_graph.
|
virtualnoexcept |
Remove all edges incident to a given vertex.
This operation is faster than removing edges one by one with remove_edge(node,node,bool,bool) since the edges are removed in bulk.
u | The node whose incident vertices are to be removed. |
norm | Normalize the graph after the deletion. |
check_norm | If norm is false then, should we check whether the result is normalized or not? This might be useful in case the resulting graph is normalized. If norm is true then check_norm is ignored. |
Reimplemented from lal::graphs::undirected_graph.
|
virtualnoexcept |
Remove a node from this graph.
u | Valid node index: \(0 \le u < n\). |
norm | Normalize the graph after the deletion. |
check_norm | If norm is false then, should we check whether the result is normalized or not? This might be useful in case the resulting graph is normalized. If norm is true then check_norm is ignored. |
Reimplemented from lal::graphs::undirected_graph.
|
privatenoexceptinherited |
Removes a single edge.
u | First node of edge. |
v | Second node of edge. |
out_u | Out-neighbourhood of node u. |
in_v | In-neighbourhood of node v. |
|
inlinenoexceptinherited |
Predicts that the degree of node u is d.
Memory of size d is reserved so that adding edges is done more efficiently.
u | Node to reserve the degree for. |
d | The amount of memory to reserve. |
|
virtualnoexcept |
Sets the edges to the graph.
Sets the edges of this graph assuming that the nodes indexed in the list are, at most, the number of nodes of this graph.
This list of edges is assumed to be all the edges that are going to be added to this graph. This means that the internal data structures are constructed more efficiently than when adding edges one by one (see add_edge) or in several chunks (see add_edges). For a more controlled addition of the edges, see can_add_edges.
Moreover, the current structure of the graph is cleared before setting the new edges.
edges | The edges to be added. |
norm | Normalize the graph after the insertions. |
check_norm | If norm is false then, should we check whether the result is normalized or not? This might be useful in case the resulting graph is normalized. If norm is true then check_norm is ignored. |
Reimplemented from lal::graphs::undirected_graph.
|
protectednoexceptinherited |
Do some work after the addition of an edge.
u | First node of the edge. |
v | Second node of the edge. |
|
protectednoexceptinherited |
Do some work after the addition of several edges.
e | List of edges. |
|
protectednoexceptinherited |
Do some work after the addition of several edges in bulk.
To be called only after veral calls to undirected_graph::add_edge_bulk or directed_graph::add_edge_bulk.
|
protectednoexceptinherited |
Do some work after the addition of several edges in bulk.
To be called only after veral calls to undirected_graph::add_edge_bulk or directed_graph::add_edge_bulk.
|
protectednoexceptinherited |
Do some work after the removal of an edge.
u | First node of the edge. |
v | Second node of the edge. |
|
protectednoexceptinherited |
Do some work after the removal of several edges.
e | List of edges. |
|
protectednoexceptinherited |
Do some work after the removal of several edges in bulk.
To be called only after veral calls to undirected_graph::remove_edge_bulk or directed_graph::remove_edge_bulk.
|
protectednoexceptinherited |
Do some work after the removal of several edges in bulk.
To be called only after veral calls to undirected_graph::remove_edge_bulk or directed_graph::remove_edge_bulk.
|
protectednoexceptinherited |
Do some work before the removal of a vertex.
u | Node to be removed. |
|
protectednoexceptinherited |
Do some work before the removal of all edges incident to a vertex.
u | Node whose incident edges are to be removed. |
|
inlineprotectednoexceptinherited |
Adds a node to this tree.
Updates all the internal data structures.
|
inlineprotectednoexceptinherited |
Initializes only the memory of class tree.
n | Number of vertices. |
|
inlineprotectednoexceptinherited |
|
protectednoexceptinherited |
Removes a vertex from the union-find data structure.
u | Node that was removed. |
|
protectednoexceptinherited |
Updates the data structures of a tree after the graph structure has had its set of edges set.
|
protectedvirtualnoexcept |
Update the union find data structure after an edge addition.
This is a helper method to be able to call lal::detail::update_unionfind_after_add_edge which updates the Union-Find data structure under addition of an edge.
u | Node that is connected to v. |
v | Node that is connected to u. |
root_of | Array of n elements relating each vertex to its root in the union find data structure. |
root_size | Array of n elements relating each vertex to the size of the connected component it belongs to. |
Implements lal::graphs::tree.
|
protectedvirtualnoexcept |
Update the union find data structure after the addition of a set of edges.
This is a helper method to be able to call lal::detail::update_unionfind_after_add_edges which updates the Union-Find data structure under addition of an edge.
edges | A set of edges. |
root_of | Array of n elements relating each vertex to its root in the union find data structure. |
root_size | Array of n elements relating each vertex to the size of the connected component it belongs to. |
Implements lal::graphs::tree.
|
protectedvirtualnoexcept |
Update the union find data structure after the addition of several edges.
This is a helper method to be able to call lal::detail::update_unionfind_after_add_rem_edges_bulk which updates the Union-Find data structure after addition of several edges.
root_of | Array of n elements relating each vertex to its root in the union find data structure. |
root_size | Array of n elements relating each vertex to the size of the connected component it belongs to. |
Implements lal::graphs::tree.
|
protectedvirtualnoexcept |
Update the union find data structure after an edge removal.
This is a helper method to be able to call lal::detail::update_unionfind_after_remove_edge which updates the Union-Find data structure under removal of an edge.
u | Node that is connected to v. |
v | Node that is connected to u. |
root_of | Array of n elements relating each vertex to its root in the union find data structure. |
root_size | Array of n elements relating each vertex to the size of the connected component it belongs to. |
Implements lal::graphs::tree.
|
protectedvirtualnoexcept |
Update the union find data structure after the removal of a set of edges.
This is a helper method to be able to call lal::detail::update_unionfind_after_remove_edges which updates the Union-Find data structure under removal of an edge.
edges | A set of edges. |
root_of | Array of n elements relating each vertex to its root in the union find data structure. |
root_size | Array of n elements relating each vertex to the size of the connected component it belongs to. |
Implements lal::graphs::tree.
|
protectedvirtualnoexcept |
Update the union find data structure after the removal of several edges.
This is a helper method to be able to call lal::detail::update_unionfind_after_add_rem_edges_bulk which updates the Union-Find data structure under removal of several edges.
root_of | Array of n elements relating each vertex to its root in the union find data structure. |
root_size | Array of n elements relating each vertex to the size of the connected component it belongs to. |
Implements lal::graphs::tree.
|
protectedvirtualnoexcept |
Update the union find data structure before the removal of all edges incident to a node.
This is a helper method to be able to call lal::detail::update_unionfind_before_remove_edges_incident_to which updates the Union-Find data structure under removal of all incident edges to a node.
u | Node whose incident edges are to be removed. |
root_of | Array of n elements relating each vertex to its root in the union find data structure. |
root_size | Array of n elements relating each vertex to the size of the connected component it belongs to. |
Implements lal::graphs::tree.
|
friend |
We want the lal::graphs::rooted_tree class to be a friend of this so as to do move operations.
|
protectedinherited |
Is this graph normalized?
An undirected graph is normalized iff every node's adjacency list is sorted in increasing order.
In directed graphs, however, it is necessary that the adjacency lists of the out-neighbors and in-neighbors of nodes be sorted.
This attribute is set to 'true' in all graph's initialisation and destruction (when clear() method is called).
|
protectedinherited |
Is the type of this tree valid?
This attribute keeps track of whether or not the function calculate_tree_type should be called before querying the type of this tree via function is_of_tree_type.
|
protectedinherited |
The size of the connected component that a root belongs to.
Formally, m_size_of[v] is the size of the connected component of a root vertex v. A vertex u is a root vertex if there exists a vertex w such that m_union_find__root_of[w] = u.
In this context, root is within the union-find data structure.