52#include <lal/linear_arrangement.hpp>
53#include <lal/graphs/directed_graph.hpp>
54#include <lal/graphs/tree.hpp>
55#include <lal/graphs/free_tree.hpp>
168 const bool norm =
true,
169 const bool check_norm =
true
192 const bool norm =
true,
193 const bool check_norm =
true
197 init_rooted(std::forward<free_tree>(t), r, norm, check_norm);
247 const bool norm =
true,
248 const bool check_norm =
true
275 const
bool norm = true,
276 const
bool check_norm = true
307 const bool connect =
false,
308 const bool norm =
true,
309 const bool check_norm =
true
338 const
bool norm = true,
339 const
bool check_norm = true
391 const std::vector<
edge>& edges,
392 const
bool norm = true,
393 const
bool check_norm = true
431 const std::vector<
edge>& edges,
432 const
bool norm = true,
433 const
bool check_norm = true
457 const
bool norm = false,
458 const
bool check_norm = true
507 const std::vector<
edge>& edges,
508 const
bool norm = true,
509 const
bool check_norm = true
531 const
bool norm = true,
532 const
bool check_norm = true
620 [[nodiscard]]
bool can_add_edges(
const std::vector<edge>& edges)
const noexcept;
622 [[nodiscard]]
bool is_rooted() const noexcept {
return true; }
722 (const
bool norm = true, const
bool check = true)
812 void _init(
const uint64_t n)
noexcept {
854 uint64_t * const root_of,
855 uint64_t * const root_size
862 uint64_t * const root_of,
863 uint64_t * const root_size
869 uint64_t * const root_of,
870 uint64_t * const root_size
878 uint64_t * const root_of,
879 uint64_t * const root_size
886 uint64_t * const root_of,
887 uint64_t * const root_size
893 uint64_t * const root_of,
894 uint64_t * const root_size
900 uint64_t * const root_of,
901 uint64_t * const root_size
932 r.m_are_size_subtrees_valid =
false;
Directed graph class.
Definition directed_graph.hpp:67
void move_full_directed_graph(directed_graph &&d) noexcept
Moves all members of this class and the parent class.
Definition directed_graph.hpp:505
directed_graph() noexcept
Empty constructor.
Definition directed_graph.hpp:72
void copy_full_directed_graph(const directed_graph &d) noexcept
Copies all members of this class and the parent class.
Definition directed_graph.hpp:497
virtual void _init(const uint64_t n) noexcept
Initializes the memory in the graph hierarchy.
Definition directed_graph.hpp:470
virtual void _clear() noexcept
Clears the memory of directed_graph and graph classes.
Definition directed_graph.hpp:475
const neighbourhood & get_in_neighbors(const node u) const noexcept
Returns the in-neighbors of node u.
Definition directed_graph.hpp:401
virtual directed_graph & add_node() noexcept
Adds a node to the graph.
Definition directed_graph.hpp:154
uint64_t get_in_degree(const node u) const noexcept
Returns the in-degree of a node.
Definition directed_graph.hpp:427
virtual directed_graph & remove_node(const node u, const bool norm=true, const bool check_norm=true) noexcept
Remove a node from this graph.
directed_graph & disjoint_union(const directed_graph &g) noexcept
Disjoint union of graphs.
Free tree graph class.
Definition free_tree.hpp:60
uint64_t get_num_nodes() const noexcept
Returns the number of ndoes.
Definition graph.hpp:207
graph() noexcept
Empty constructor.
Definition graph.hpp:73
bool has_node(const node u) const noexcept
Returns true if node u is in this graph.
Definition graph.hpp:201
Rooted tree graph class.
Definition rooted_tree.hpp:109
void finish_bulk_add(const bool norm=true, const bool check=true) noexcept
Finishes adding edges in bulk.
rooted_tree(rooted_tree &&r) noexcept
Move constructor.
Definition rooted_tree.hpp:149
void actions_before_remove_edges_incident_to(const node u) noexcept
Do some work before all edges incident to a node is removed.
free_tree to_free_tree(const bool norm=true, const bool check=true) const noexcept
Converts this rooted tree into a free tree (see free_tree).
void copy_full_rooted_tree(const rooted_tree &r) noexcept
Copies all members of this class and the parent classes.
Definition rooted_tree.hpp:906
void _clear() noexcept
Clears the memory in the graph hierarchy.
Definition rooted_tree.hpp:827
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_bulk() noexcept
Do some extra work after the addition of several edges in bulk.
void actions_after_remove_node(const node u) noexcept
Do some work before the removal of a vertex.
bool can_add_edge(const node s, const node t) const noexcept
Can this edge be added?
rooted_tree & add_node() noexcept
Adds a node to the graph.
Definition rooted_tree.hpp:280
void set_root(const node r) noexcept
Set the root of this tree.
Definition rooted_tree.hpp:586
rooted_tree & remove_edge_bulk(const node s, const node t) noexcept
Removes an edge from the tree.
head_vector get_head_vector(const linear_arrangement &arr={}) const noexcept
Converts a rooted tree into a head vector.
std::optional< node > m_root
Root of the tree.
Definition rooted_tree.hpp:791
rooted_tree & operator=(const rooted_tree &r) noexcept
Copy assignment operator.
Definition rooted_tree.hpp:209
rooted_tree & remove_edges(const std::vector< edge > &edges, const bool norm=true, const bool check_norm=true) noexcept
Remove an edge from this graph.
~rooted_tree() noexcept
Destructor.
Definition rooted_tree.hpp:201
void actions_after_add_edges(const edge_list &e) noexcept
Do some extra work after the addition of several 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.
rooted_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.
rooted_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.
void calculate_size_subtrees() noexcept
Calculates the number of nodes at every rooted subtree.
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.
void actions_after_remove_edges_bulk() noexcept
Do some extra work after the removal of several 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.
bool is_root_valid(const node r) const noexcept
Is the root valid?
Definition rooted_tree.hpp:611
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.
rooted_tree & add_edge_bulk(const node s, const node t) noexcept
Adds an edge to the graph.
void actions_after_remove_edge(const node u, const node v) noexcept
Do some extra work after the removal of an edge.
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.
std::vector< uint64_t > m_size_subtrees
Number of nodes of the subtrees rooted at a certain node.
Definition rooted_tree.hpp:799
void actions_after_remove_edges(const edge_list &e) noexcept
Do some extra work after the removal of several edges.
rooted_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.
bool are_nodes_siblings(const node u, const node v) const noexcept
Are two nodes siblings?
Definition rooted_tree.hpp:757
rooted_tree(free_tree &&t, const node r, const bool norm=true, const bool check_norm=true) noexcept
Constructor with tree and root node.
Definition rooted_tree.hpp:189
bool has_root() const noexcept
Definition rooted_tree.hpp:645
node get_root() const noexcept
Return the root of this tree.
Definition rooted_tree.hpp:637
std::vector< edge > get_edges_subtree(const node u, const bool relab=false) const noexcept
Retrieve the edges of the subtree rooted at u.
bool is_rooted() const noexcept
Returns whether this tree is a rooted tree.
Definition rooted_tree.hpp:622
rooted_tree(const directed_graph &t) noexcept
Copy constructor with directed graph.
rooted_tree(const rooted_tree &r) noexcept
Copy constructor.
Definition rooted_tree.hpp:141
void finish_bulk_remove(const bool norm=true, const bool check=true) noexcept
Finishes removing edges in bulk.
void calculate_tree_type() noexcept
Calculates the type of tree.
bool subtree_contains_node(const node r, const node u) const noexcept
Does the subtree rooted at r contain node u?
rooted_tree(const free_tree &t, const node r, const bool norm=true, const bool check_norm=true) noexcept
Constructor with free tree and root node.
Definition rooted_tree.hpp:165
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_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.
rooted_tree() noexcept
Empty constructor.
Definition rooted_tree.hpp:114
rooted_tree & remove_node(const node u, const bool connect=false, const bool norm=true, const bool check_norm=true) noexcept
Remove a node from this tree.
rooted_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.
rooted_tree(directed_graph &&t) noexcept
Move constructor with directed graph.
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.
bool can_add_edges(const std::vector< edge > &edges) const noexcept
Can these edges be added?
void init_rooted(const free_tree &t, const node r, const bool norm=true, const bool check_norm=true) noexcept
Initializer with tree and root node.
void move_full_rooted_tree(rooted_tree &&r) noexcept
Moves all members of this class and the parent classes.
Definition rooted_tree.hpp:919
node get_parent_node(const node u) const noexcept
Parent vertex of a node.
Definition rooted_tree.hpp:782
rooted_tree & disjoint_union(const rooted_tree &t, const bool connect_roots=true) noexcept
Disjoint union of trees.
void _init(const uint64_t n) noexcept
Initializes the memory in the graph hierarchy.
Definition rooted_tree.hpp:812
uint64_t get_num_nodes_subtree(const node u) const noexcept
Get the size of a subtree rooted at a given node.
Definition rooted_tree.hpp:653
bool are_size_subtrees_valid() const noexcept
Is a recalculation of the subtree's sizes needed?
Definition rooted_tree.hpp:671
bool node_has_parent(const node u) const noexcept
Does a node have a parent vertex?
Definition rooted_tree.hpp:772
rooted_tree get_subtree(const node u) const noexcept
Retrieve the subtree rooted at node u.
rooted_tree & set_edges(const std::vector< edge > &edges, const bool norm=true, const bool check_norm=true) noexcept
Sets the edges to the graph.
bool is_rooted_tree() const noexcept
Is this tree a valid rooted tree?
Definition rooted_tree.hpp:634
rooted_tree(const uint64_t n) noexcept
Constructor with number of nodes and root node.
Definition rooted_tree.hpp:119
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.
bool m_are_size_subtrees_valid
Are the contents of m_size_subtrees valid?
Definition rooted_tree.hpp:801
Tree graph class.
Definition tree.hpp:73
bool is_tree() const noexcept
Is this graph an actual tree?
Definition tree.hpp:177
tree() noexcept
Empty constructor.
Definition tree.hpp:78
void tree_only_invalidate() noexcept
Invalidates the aggregated information of the tree.
Definition tree.hpp:395
void tree_only_copy(const tree &t) noexcept
Copies only members of class tree.
Definition tree.hpp:359
void tree_only_move(tree &&t) noexcept
Moves only members of class tree.
Definition tree.hpp:367
void tree_only_add_node() noexcept
Adds a node to this tree.
Definition tree.hpp:382
void tree_only_init(const uint64_t n) noexcept
Initializes only the memory of class tree.
Definition tree.hpp:340
void tree_only_clear() noexcept
Clears the memory used by only class tree.
Definition tree.hpp:351
Linear arrangement of vertices.
Definition linear_arrangement.hpp:103
Main namespace of the library.
Definition basic_types.hpp:48
std::vector< uint64_t > head_vector
See Head vector page for further details.
Definition basic_types.hpp:58
std::pair< node, node > edge
See Edge page for further details.
Definition basic_types.hpp:56
std::vector< edge > edge_list
See Edge list page for further details.
Definition basic_types.hpp:60
uint64_t node
Node type. See Node / Vertex page for further details.
Definition basic_types.hpp:51