LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
|
Detail namespace. More...
Namespaces | |
namespace | bipartite_opt_utils |
Utilities for the various optimal linear arrangement algorithms. | |
namespace | crossings |
Namespace for the algorithms that compute the number of crossings. | |
namespace | DMax |
Namespace for algorithms to calculate the maximum sum of edge lengths. | |
namespace | DMax_utils |
Utilities for the various maximum linear arrangement algorithms. | |
namespace | Dmin |
Namespace for algorithms to calculate the minimum sum of edge lengths. | |
namespace | Dmin_utils |
Utilities for the various minimum linear arrangement algorithms. | |
namespace | Dopt_utils |
Utilities for the various optimal linear arrangement algorithms. | |
namespace | maximum_subtrees |
Algorithms to find maximum subtrees. | |
namespace | sorting |
Sorting algorithms. | |
Classes | |
class | arrangement_wrapper |
A wrapper to easily use identity arrangements. More... | |
struct | array |
Wrapper of a C array for automatic deallocation of memory. More... | |
class | AVL |
Simple class that implements an AVL tree. More... | |
class | BFS |
Abstract graph Breadth-First Search traversal. More... | |
struct | bool_sequence |
A sequence of Boolean values. More... | |
class | chunks_Anderson |
Implementation of Anderson's algorithm for chunking. More... | |
class | chunks_generic |
Basic algorithms existent in every definition of chunking. More... | |
class | chunks_Macutek |
Implementation of Mačutek's algorithm for chunking. More... | |
struct | conditional_list |
Generalization of std::conditional_list. More... | |
struct | edge_size |
Struct used in many algorithms to sort edges according to some integer value. More... | |
struct | first_true |
From a list of Boolean values, find the first that is set to true. More... | |
struct | is_pointer_iterator |
Decide if a type is a pointer or iterator to another. More... | |
struct | ith_type |
Selection of the ith type of a list of types. More... | |
struct | ith_type< ith_idx, type_sequence< Ts... > > |
Partial template specialization of ith_type for type_sequence. More... | |
class | level_signature |
A class that implements level signatures of an array. More... | |
struct | node_size |
Struct used in many algorithms to sort vertices according to some integer value. More... | |
class | queue_array |
Simple array-like fixed-size queue. More... | |
class | set_array |
A set-like data structure implemented with an array. More... | |
struct | type_sequence |
A sequence of types. More... | |
Typedefs | |
typedef level_signature< level_signature_type::per_vertex > | level_signature_per_vertex |
A useful typedef for level signatures per vertex. | |
typedef level_signature< level_signature_type::per_position > | level_signature_per_position |
A useful typedef for level signatures per position. | |
template<typename bool_seq , typename type_seq > | |
using | conditional_list_t = typename conditional_list<bool_seq, type_seq>::type |
Shorthand for conditional_list. | |
template<std::size_t ith_idx, typename... Ts> | |
using | ith_type_t = typename ith_type<ith_idx, Ts...>::type |
Shorthand for ith_type::type. | |
Enumerations | |
enum class | arrangement_type { identity , nonidentity } |
Type of arrangement. More... | |
enum class | level_signature_type { per_vertex , per_position } |
Types of level signature. More... | |
enum class | centroid_results { only_one_centroidal , full_centroid , full_centroid_plus_subtree_sizes , full_centroid_plus_edge_sizes } |
The different types of results. More... | |
Functions | |
arrangement_wrapper< arrangement_type::identity > | identity_arr (const linear_arrangement &arr) noexcept |
Shorthand for an identity arrangement. | |
arrangement_wrapper< arrangement_type::nonidentity > | nonidentity_arr (const linear_arrangement &arr) noexcept |
Shorthand for a nonidentity arrangement. | |
template<class container > | |
void | make_arrangement_permutations (const graphs::rooted_tree &T, const node r, const container &data, position &pos, linear_arrangement &arr) noexcept |
Make an arrangement using permutations. | |
template<class container > | |
linear_arrangement | make_arrangement_permutations (const graphs::rooted_tree &T, const container &data) noexcept |
Make an arrangement using permutations. | |
template<class container > | |
void | make_arrangement_permutations (const graphs::free_tree &T, node parent, node u, const container &data, position &pos, linear_arrangement &arr) noexcept |
Make an arrangement using permutations. | |
template<class container > | |
linear_arrangement | make_arrangement_permutations (const graphs::free_tree &T, node root, const container &data) noexcept |
Make an arrangement using permutations. | |
template<class graph_t > | |
graph_t | from_edge_list_to_graph (const edge_list &edge_list, const bool normalize, const bool check) noexcept |
Converts an edge list into a graph. | |
template<class graph_t > | |
graph_t | from_head_vector_to_graph (const head_vector &hv, const bool normalize, const bool check) noexcept |
Transforms a head vector in a directed graph. | |
template<typename tree_t , bool ensure_root_is_returned, bool free_tree_plus_root = ensure_root_is_returned and std::is_same_v<tree_t, graphs::free_tree>> | |
std::conditional_t< free_tree_plus_root, std::pair< tree_t, node >, tree_t > | from_head_vector_to_tree (std::stringstream &ss) noexcept |
Transforms a head vector in a tree. | |
template<class tree_t , bool is_rooted = std::is_base_of_v<graphs::rooted_tree, tree_t>> | |
std::conditional_t< is_rooted, graphs::rooted_tree, std::pair< graphs::free_tree, node > > | from_head_vector_to_tree (const head_vector &hv, const bool normalize, const bool check) noexcept |
Converts a head vector into a tree. | |
template<class arrangement_t > | |
head_vector | from_tree_to_head_vector (const graphs::rooted_tree &t, const arrangement_t &arr) noexcept |
Constructs the head vector representation of a tree. | |
template<class arrangement_t > | |
head_vector | from_tree_to_head_vector (const graphs::free_tree &t, const arrangement_t &arr, const node r) noexcept |
Constructs the head vector representation of a tree. | |
template<class tree_t > | |
tree_t | from_level_sequence_to_tree_small (const uint64_t *const L, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the level sequence of a tree into a graph structure. | |
template<class tree_t > | |
tree_t | from_level_sequence_to_tree_large (const uint64_t *const L, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the level sequence of a tree into a graph structure. | |
template<class tree_t > | |
tree_t | from_level_sequence_to_tree (const uint64_t *const L, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the level sequence of a tree into a graph structure. | |
template<class tree_t > | |
tree_t | from_level_sequence_to_tree_small (const std::vector< uint64_t > &L, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the level sequence of a tree into a graph structure. | |
template<class tree_t > | |
tree_t | from_level_sequence_to_tree_large (const std::vector< uint64_t > &L, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the level sequence of a tree into a graph structure. | |
template<class tree_t > | |
tree_t | from_level_sequence_to_tree (const std::vector< uint64_t > &L, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the level sequence of a tree into a graph structure. | |
graphs::free_tree | from_Prufer_sequence_to_ftree (const uint64_t *const seq, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the Prüfer sequence of a labelled tree into a tree structure. | |
graphs::free_tree | from_Prufer_sequence_to_ftree (const std::vector< uint64_t > &seq, const uint64_t n, const bool normalize, const bool check) noexcept |
Converts the Prüfer sequence of a labelled tree into a tree structure. | |
bool | find_cycle (const graphs::directed_graph &g, const node u, char *const __restrict__ visited, char *const __restrict__ in_stack) noexcept |
Returns true if, and only if, the graph has cycles. | |
bool | has_directed_cycles (const graphs::directed_graph &g, char *const __restrict__ vis, char *const __restrict__ in_stack) noexcept |
Returns true if, and only if, the graph has DIRECTED cycles. | |
bool | has_directed_cycles (const graphs::directed_graph &g) noexcept |
Returns true if, and only if, the graph has DIRECTED cycles. | |
template<class graph_t > | |
bool | has_undirected_cycles (const graph_t &g, BFS< graph_t > &bfs) noexcept |
Returns true if, and only if, the graph has UNDIRECTED cycles. | |
template<class graph_t > | |
bool | has_undirected_cycles (const graph_t &g) noexcept |
Returns true if, and only if, the graph has UNDIRECTED cycles. | |
template<class graph_t > | |
std::vector< edge > | set_edges (const graph_t &g) noexcept |
Enumerate the set of edges of the input graph g. | |
template<class graph_t > | |
std::vector< edge_pair > | set_pairs_independent_edges (const graph_t &g, const uint64_t qs) noexcept |
Enumerate the set of pairs of independent edges of the input graph g. | |
template<class graph_t > | |
bool | is_graph_a_tree (const graph_t &g) noexcept |
Is the input graph a tree? | |
template<class graph_t > | |
bool | is_node_reachable_from (const graph_t &g, const node source, const node target) noexcept |
Is a node reachable from another? | |
template<bool get_subsizes> | |
std::pair< std::vector< edge >, uint64_t * > | get_edges_subtree (const graphs::rooted_tree &T, const node u, const bool relabel) noexcept |
Retrieves the edges of a subtree. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
void | get_size_subtrees (const tree_t &t, const node u, const node v, uint64_t *const sizes) noexcept |
Calculate the size of every subtree of the tree t. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
void | get_size_subtrees (const tree_t &t, const node r, uint64_t *const sizes) noexcept |
Calculate the size of every subtree of tree t. | |
template<class tree_t , typename iterator_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t > and is_pointer_iterator_v< edge_size, iterator_t >, bool > = true> | |
uint64_t | calculate_bidirectional_sizes (const tree_t &t, const uint64_t n, const node u, const node v, iterator_t &it) noexcept |
Calculates the values \(s(u,v)\) for the edges \((s,t)\) reachable from \(v\) in the subtree \(T^u_v\). | |
template<class tree_t , typename iterator_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t > and is_pointer_iterator_v< edge_size, iterator_t >, bool > = true> | |
void | calculate_bidirectional_sizes (const tree_t &t, const uint64_t n, const node x, iterator_t it) noexcept |
Calculates the values \(s_u(v)\) for the edges \((u,v)\) reachable from vertex x. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
void | classify_tree (const tree_t &t, std::array< bool, graphs::__tree_type_size > &tree_types) noexcept |
Classify a tree into one of the types graphs::tree_type. | |
constexpr std::string_view | tree_type_string (const graphs::tree_type &tt) noexcept |
Converts to a string a value of the enumeration lal::graphs::tree_type. | |
template<class tree_t > | |
void | update_unionfind_after_add_edge (const tree_t &t, const node u, const node v, node *const root_of, uint64_t *const root_size) noexcept |
Update the Union-Find data structure after the addition of an edge. | |
template<class tree_t > | |
void | update_unionfind_after_add_edges (const tree_t &t, const edge_list &edges, node *const root_of, uint64_t *const root_size) noexcept |
Update the Union-Find data structure after the addition of several edges. | |
template<class tree_t > | |
void | update_unionfind_after_add_rem_edges_bulk (const tree_t &t, node *const root_of, uint64_t *const root_size) noexcept |
Update the Union-Find data structure after several edges have been operated in bulk. | |
template<class tree_t > | |
void | update_unionfind_after_remove_edge (const tree_t &t, const node u, const node v, node *const root_of, uint64_t *const root_size) noexcept |
Updates Union-Find after the removal of an edge. | |
template<class tree_t > | |
void | update_unionfind_after_remove_edges (const tree_t &t, const edge_list &edges, node *const root_of, uint64_t *const root_size) noexcept |
Update the Union-Find data structure after the addition of several edges. | |
template<class tree_t > | |
void | update_unionfind_before_remove_edges_incident_to (BFS< tree_t > &bfs, const node v, node *const root_of, uint64_t *const root_size) noexcept |
Update Union-Find after the removal of a vertex. | |
template<typename tree_t > | |
void | update_unionfind_before_remove_edges_incident_to (const tree_t &t, const node u, node *const root_of, uint64_t *const root_size) noexcept |
Update Union-Find after a vertex removal. | |
template<class graph_t , typename char_type , std::enable_if_t< std::is_base_of_v< graphs::graph, graph_t > and std::is_integral_v< char_type >, bool > = true> | |
void | get_bool_neighbors (const graph_t &g, const node u, char_type *const neighs) noexcept |
Retrieves the neighbors of a node in an undirected graph as a list of 0-1 values. | |
void | append_adjacency_lists (std::vector< neighbourhood > &target, const std::vector< neighbourhood > &source) noexcept |
Append adjacency list 'source' to list 'target'. | |
template<bool decide> | |
std::conditional_t< decide, bool, std::vector< io::head_vector_error > > | find_errors (const head_vector &hv) noexcept |
Find errors in a head vector. | |
template<bool decide> | |
std::conditional_t< decide, bool, std::vector< io::head_vector_error > > | find_errors (const std::string ¤t_line) noexcept |
Find errors in a line of a treebank. | |
template<bool decide> | |
std::conditional_t< decide, bool, io::treebank_file_report > | check_correctness_treebank (const std::string &treebank_filename) noexcept |
Find errors in a treebank file. | |
template<bool decide> | |
std::conditional_t< decide, bool, io::treebank_collection_report > | check_correctness_treebank_collection (const std::string &main_file_name, const std::size_t n_threads) noexcept |
Find errors in a treebank collection. | |
template<class graph_t > | |
uint64_t | n_C_brute_force (const graph_t &g, const linear_arrangement &arr) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
std::vector< uint64_t > | n_C_brute_force (const graph_t &g, const std::vector< linear_arrangement > &arrs) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
uint64_t | is_n_C_brute_force_lesseq_than (const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept |
Returns whether the number of crossings is less than a given constant. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_brute_force_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const uint64_t upper_bound) noexcept |
Returns whether the number of crossings is less than a given constant. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_brute_force_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const std::vector< uint64_t > &upper_bounds) noexcept |
Returns whether the number of crossings is less than a given constant. | |
template<class graph_t > | |
uint64_t | n_C_dynamic_programming (const graph_t &g, const linear_arrangement &arr) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
std::vector< uint64_t > | n_C_dynamic_programming (const graph_t &g, const std::vector< linear_arrangement > &arrs) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
uint64_t | is_n_C_dynamic_programming_lesseq_than (const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_dynamic_programming_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const uint64_t upper_bound) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_dynamic_programming_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const std::vector< uint64_t > &upper_bounds) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
uint64_t | n_C_ladder (const graph_t &g, const linear_arrangement &arr) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
std::vector< uint64_t > | n_C_ladder (const graph_t &g, const std::vector< linear_arrangement > &arrs) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
uint64_t | is_n_C_ladder_lesseq_than (const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_ladder_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const uint64_t upper_bound) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_ladder_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const std::vector< uint64_t > &upper_bounds) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
uint64_t | n_C_stack_based (const graph_t &g, const linear_arrangement &arr) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
std::vector< uint64_t > | n_C_stack_based (const graph_t &g, const std::vector< linear_arrangement > &arrs) noexcept |
Is the number of crossings in the linear arrangement less than a constant? | |
template<class graph_t > | |
uint64_t | is_n_C_stack_based_lesseq_than (const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_stack_based_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const uint64_t upper_bound) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
template<class graph_t > | |
std::vector< uint64_t > | is_n_C_stack_based_lesseq_than (const graph_t &g, const std::vector< linear_arrangement > &arrs, const std::vector< uint64_t > &upper_bounds) noexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound. | |
constexpr uint64_t | alpha (const int64_t n, const int64_t d1, const int64_t d2) noexcept |
Amount of crossings pairs of edges of given lengths. | |
constexpr uint64_t | beta (const int64_t n, const int64_t d1, const int64_t d2) noexcept |
Amount of pairs of edges of given lengths. | |
template<typename result_t , class graph_t , class arrangement_t > | |
result_t | predict_C_using_edge_lengths (const graph_t &g, const arrangement_t &arr) noexcept |
Predicted number of crossings based on the sum of edge lengths. | |
template<class graph_t , class arrangement_t > | |
uint64_t | sum_edge_lengths (const graph_t &g, const arrangement_t &arr) noexcept |
Sum of edge lengths in a graph. | |
template<class result_t , class graph_t , class arrangement_t > | |
result_t | mean_sum_edge_lengths (const graph_t &g, const arrangement_t &arr) noexcept |
Average sum of edge lengths in a graph. | |
template<class graph_t , level_signature_type t> | |
bool | is_level_signature_nonincreasing (const graph_t &g, const level_signature< t > &levels, const linear_arrangement &arr) noexcept |
Returns true if the level sequence follows that of a maximum arrangement. | |
template<class graph_t , level_signature_type t> | |
bool | no_two_adjacent_vertices_have_same_level (const graph_t &g, const level_signature< t > &levels, const linear_arrangement &arr) noexcept |
Returns true if no two adjacent vertices (in the graph) have the same level value. | |
template<class graph_t , level_signature_type t> | |
bool | no_vertex_in_antenna_is_thistle (const graph_t &g, const std::vector< properties::branchless_path > &bps, const level_signature< t > &levels, const linear_arrangement &arr) noexcept |
Returns true if none of the vertices in the antennas of the graph is a thistle. | |
template<class graph_t , level_signature_type t> | |
bool | at_most_one_thistle_in_bridges (const graph_t &g, const std::vector< properties::branchless_path > &bps, const level_signature< t > &levels, const linear_arrangement &arr) noexcept |
Returns true if none of the vertices in the antennas of the graph is a thistle. | |
template<class depflux , class arrangement_t > | |
void | calculate_dependencies_and_span (const graphs::free_tree &t, const arrangement_t &arr, const std::vector< std::pair< edge_t, uint64_t > > &edge_with_max_pos_at, const position cur_pos, std::vector< depflux > &flux, std::vector< edge > &cur_deps) noexcept |
Calculate the dependencies and their span. | |
uint64_t | calculate_weight (const std::vector< edge > &dependencies, graphs::undirected_graph &ug) noexcept |
Calculates the weight of a set of dependencies in a flux. | |
template<class arrangement_t > | |
bool | is_root_covered (const graphs::rooted_tree &rt, const arrangement_t &arr) noexcept |
Is the root of a rooted tree covered in a given arrangement? | |
template<class arrangement_t > | |
bool | is_projective (const graphs::rooted_tree &rt, const arrangement_t &arr) noexcept |
Is a given arrangement projective? | |
template<class arrangement_t > | |
bool | is_bipartite__connected (const properties::bipartite_graph_coloring &c, const arrangement_t &arr) noexcept |
Is a given arrangement bipartite? | |
template<class graph_t , class arrangement_t > | |
bool | is_bipartite (const graph_t &g, const arrangement_t &arr) noexcept |
Is a given arrangement bipartite? | |
template<class arrangement_t > | |
uint64_t | right_branching_edges (const graphs::directed_graph &g, const arrangement_t &arr) noexcept |
Number of right branching edges in a directed graph. | |
template<typename result_t , class arrangement_t > | |
result_t | head_initial (const graphs::directed_graph &g, const arrangement_t &arr) noexcept |
Proposition of right branching edges in a directed graph. | |
constexpr bool | is_per_vertex (const level_signature_type &t) noexcept |
Returns true if the template parameter is lal::detail::level_signature_type::per_vertex. | |
constexpr bool | is_per_position (const level_signature_type &t) noexcept |
Returns true if the template parameter is lal::detail::level_signature_type::per_position. | |
template<level_signature_type t, class graph_t > | |
bool | is_thistle_vertex (const graph_t &g, const level_signature< t > &levels, const node_t u, const linear_arrangement &arr={}) noexcept |
Returns whether or not the input vertex is a thistle vertex. | |
template<level_signature_type t, class graph_t > | |
void | calculate_level_signature (const graph_t &g, const linear_arrangement &arr, level_signature< t > &L) noexcept |
Calculates the level signature of an arrangement of a graph. | |
template<level_signature_type t, class graph_t > | |
level_signature< t > | calculate_level_signature (const graph_t &g, const linear_arrangement &arr) noexcept |
Calculates the level signature of an arrangement of a graph. | |
template<class level_signature_t > | |
level_signature_t | mirror_level_signature (const level_signature_t &L) noexcept |
Mirrors a level signature. | |
constexpr std::string_view | syntactic_dependency_tree_to_string (const linarr::syntactic_dependency_tree_type &tt) noexcept |
template<typename T > | |
constexpr uint64_t | to_uint64 (const T &t) noexcept |
Conversion to uint64_t. | |
template<typename T > | |
constexpr int64_t | to_int64 (const T &t) noexcept |
Conversion to int64_t. | |
template<typename T > | |
constexpr uint32_t | to_uint32 (const T &t) noexcept |
Conversion to uint32_t. | |
template<typename T > | |
constexpr int32_t | to_int32 (const T &t) noexcept |
Conversion to int32_t. | |
template<typename T > | |
constexpr double | to_double (const T &t) noexcept |
Conversion to double. | |
template<typename T > | |
constexpr T | abs_diff (const T &t1, const T &t2) noexcept |
Absolute difference of two values. | |
template<typename iterator_t , typename value_t > | |
iterator_t | find_sorted (const iterator_t begin, const iterator_t end, const std::size_t size, const value_t &v, const std::size_t min_size=64) noexcept |
Finds an element within the sorted range [begin, end). | |
template<typename iterator_t , typename value_t > | |
bool | exists_sorted (const iterator_t begin, const iterator_t end, const std::size_t size, const value_t &v, const std::size_t min_size=64) noexcept |
Finds an element within the sorted range [begin, end). | |
template<typename T , std::size_t size, T v, std::size_t... I> | |
constexpr std::array< T, size > | make_array_with_value_impl (std::index_sequence< I... >) noexcept |
Implementation of lal::detail::make_array_with_value. | |
template<typename T , std::size_t array_size, T value_to_fill_with> | |
constexpr std::array< T, array_size > | make_array_with_value () noexcept |
Returns an array initialized at a given value. | |
template<typename T , T... ARGS> | |
constexpr std::array< T, sizeof...(ARGS)> | make_array () noexcept |
Make an array with the values given as parameters of the template. | |
void | mpz_pow_mpz (mpz_t &r, const mpz_t &b, const mpz_t &e) noexcept |
Computes the exponentiation of a big integer to another big integer. | |
void | mpz_divide_mpq (mpq_t &r, const mpz_t &k) noexcept |
Rational-Integer division. | |
void | mpq_divide_mpq (mpq_t &num, const mpq_t &den) noexcept |
Rational-Rational division. | |
void | operate_power (mpq_t &r, uint64_t p) noexcept |
Power operation. | |
void | operate_power (mpq_t &r, const mpz_t &p) noexcept |
Power operation. | |
std::size_t | mpz_bytes (const mpz_t &v) noexcept |
Returns the amount of bytes of a gmp's integer value. | |
template<class tree_t > | |
void | expand_branchless_path (const tree_t &t, const node u, const node v, BFS< tree_t > &bfs, std::vector< properties::branchless_path > &res, properties::branchless_path &p) noexcept |
Completes the branchless path. | |
template<class tree_t > | |
std::vector< properties::branchless_path > | branchless_paths_compute (const tree_t &t) noexcept |
Finds all branchless paths in a tree. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
std::pair< node, node > | retrieve_centre (const tree_t &t, const node X) noexcept |
Calculate the centre of the connected component that has node x. | |
constexpr bool | is_m1 (const centroid_results &m) noexcept |
Is mode m equal to lal::detail::centroid_results::only_one_centroidal. | |
constexpr bool | is_m2 (const centroid_results &m) noexcept |
Is mode m equal to lal::detail::centroid_results::full_centroid. | |
constexpr bool | is_m3 (const centroid_results &m) noexcept |
Is mode m equal to lal::detail::centroid_results::full_centroid_plus_subtree_sizes. | |
constexpr bool | is_m4 (const centroid_results &m) noexcept |
Is mode m equal to lal::detail::centroid_results::full_centroid_plus_edge_sizes. | |
template<centroid_results mode, class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
conditional_list_t< bool_sequence< is_m1(mode), is_m2(mode), is_m3(mode), is_m4(mode) >, type_sequence< node, std::pair< node, node >, std::pair< std::pair< node, node >, array< uint64_t > >, std::pair< std::pair< node, node >, array< edge_size > > > > | find_centroidal_vertex (const tree_t &t, const node x) noexcept |
Calculates the centroid of a tree. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
std::pair< node, node > | centroidal_vertex_plus_adjacency_list (const tree_t &t, const node x, std::vector< std::vector< node_size > > &L) noexcept |
Calculates the centroid and the corresponding rooted adjacency list. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
std::pair< node, node > | retrieve_centroid (const tree_t &t, const node x=0) noexcept |
Calculate the centroid of the connected component that has node x. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
uint64_t | tree_diameter (const tree_t &t, const node x) noexcept |
Calculate the diameter of a tree. | |
template<class tree_t , std::enable_if_t< std::is_base_of_v< graphs::tree, tree_t >, bool > = true> | |
char | fast_non_iso (const tree_t &t1, const tree_t &t2) noexcept |
Fast tree non-isomorphism test. | |
void | assign_name_and_keep (const graphs::rooted_tree &t, const node u, std::size_t idx, array< std::string > &aux_memory_for_names, array< std::string > &keep_name_of) noexcept |
Assigns a name to node 'u', root of the current subtree. | |
std::string | assign_name (const graphs::rooted_tree &t, const node u, array< std::string > &names, std::size_t idx) noexcept |
Assigns a name to node 'u', root of the current subtree. | |
bool | are_rooted_trees_isomorphic (const graphs::rooted_tree &t1, const graphs::rooted_tree &t2) noexcept |
Test whether two rooted trees are isomorphic or not. | |
Variables | |
constexpr std::array< graphs::tree_type, graphs::__tree_type_size > | array_of_tree_types |
The array of all types of trees. | |
constexpr std::array< linarr::syntactic_dependency_tree_type, linarr::__syntactic_dependency_tree_size > | array_of_syntactic_dependency_trees |
The array of all types of syntact dependency structures. | |
template<bool... conds> | |
static constexpr std::size_t | first_true_v = first_true<conds...>::value |
Shorthand for first_true. | |
template<typename Iterated_Type , typename Iterator > | |
constexpr bool | is_pointer_iterator_v |
Shorthand for is_pointer_iterator. | |
Detail namespace.
Most algorithms are included here. Unless you have a really good reason to use the algorithms in this namespace, please, refrain from doing so.
|
strong |
|
strong |
The different types of results.
Enumerator | |
---|---|
only_one_centroidal | Returns only one centroidal vertex. No weights. |
full_centroid | Returns the full centroid of the tree. No weights. |
full_centroid_plus_subtree_sizes | Returns the full centroid of the tree. Also returns the weights. |
full_centroid_plus_edge_sizes | Returns the full centroid of the tree. Also returns the edge_size array. |
|
strong |
|
inlinenodiscardconstexprnoexcept |
Amount of crossings pairs of edges of given lengths.
Complexity: constant time.
n | Number of edges in the linear arrangement. |
d1 | Length of the first edge. |
d2 | Length of the second edge. |
|
inlinenoexcept |
Append adjacency list 'source' to list 'target'.
target | List into which source will be appended to. |
source | List to append to target. |
|
inlinenodiscardnoexcept |
Test whether two rooted trees are isomorphic or not.
t1 | First rooted tree. |
t2 | Second rooted tree. |
|
inlinenodiscardnoexcept |
Assigns a name to node 'u', root of the current subtree.
For further details on the algorithm, see [1] for further details.
t | Input rooted tree |
u | Root of the subtree whose name we want to calculate |
names | An array of strings where the names are stored (as in a dynamic programming algorithm). The size of this array must be at least the number of vertices in the subtree of 't' rooted at 'u'. Actually, less memory suffices, but I don't know how much less: better be safe than sorry. |
idx | A pointer to the position within names that will contain the name of the first child of 'u'. The position names[idx+1] will contain the name of the second child of 'u'. |
|
inlinenoexcept |
Assigns a name to node 'u', root of the current subtree.
This function stores the names of every node in the subtree rooted at 'u'. This is useful if we want to make lots of comparisons between subtrees
For further details on the algorithm, see [1].
t | Input rooted tree |
u | Root of the subtree whose name we want to calculate |
idx | A pointer to the position within names that will contain the name of the first child of 'u'. The position names[idx+1] will contain the name of the second child of 'u'. |
aux_memory_for_names | Auxiliary memory used to sort names of subtrees. |
keep_name_of | An array of strings where the names are stored (as in a dynamic programming algorithm). The size of this array must be at least the number of vertices in the subtree of 't' rooted at 'u'. Actually, less memory suffices, but better be safe than sorry. |
|
inlinenodiscardnoexcept |
Returns true if none of the vertices in the antennas of the graph is a thistle.
Checks that no vertex in any antenna of the tree is a thistle vertex in the input arrangement. This is a necessary condition for an arrangement to be maximum (in sum of edge lengths), as shown in [7].
When the level signature is defined on a 'per vertex' basis, the arrangement is not needed.
t | Level signature type. |
graph_t | Type of graph. |
g | Input graph. |
arr | Input arrangement. |
levels | signature of the arrangement. |
bps | All Branchless Paths of the tree. |
|
inlinenodiscardconstexprnoexcept |
Amount of pairs of edges of given lengths.
Complexity: constant time.
n | Number of edges in the linear arrangement. |
d1 | Length of the first edge. |
d2 | Length of the second edge. |
|
nodiscardnoexcept |
Finds all branchless paths in a tree.
tree_t | Type of tree. |
t | Input tree. |
|
nodiscardnoexcept |
Calculates the values \(s(u,v)\) for the edges \((s,t)\) reachable from \(v\) in the subtree \(T^u_v\).
This function calculates the 'map' relating each edge \((u, v)\) with the size of the subtree rooted at \(v\) with respect to the hypothetical root \(u\). This is an implementation of the algorithm described in [30] (proof of lemma 8 (page 63), and the beginning of section 6 (page 65)).
Notice that the values are not stored in an actual map (std::map, or similar), but in a vector.
iterated_t | The type that stores the sizes. |
iterator_t | The type of the iterator on a container containing values of type iterated_t. |
t | Input tree. |
n | Size of the connected component to which edge \((u,v)\) belongs to. |
u | First vertex of the edge. |
v | Second vertex of the edge. |
it | An iterator to the container that holds the size values. Such container must have size equal to twice the number of edges in the connected component of u and v. |
|
inlinenoexcept |
Calculates the values \(s_u(v)\) for the edges \((u,v)\) reachable from vertex x.
Calculates the values \(s_u(v)\) for all edges \((u,v)\) in linear time. This is an implementation of the algorithm described in [30] (proof of lemma 8 (page 63), and the beginning of section 6 (page 65)).
For any edge \((u,v)\) let \(T^u\) be the tree \(T\) rooted at \(u\). The value \(s_u(v)\) is the size of the subtree of \(T^u\) rooted at \(v\), i.e., \(s_u(v)=|V(T^u_v)|\).
Example of usage (mind the vector! its initial size is \(2*m\)).
tree_t | Type of the tree. Must be 'rooted_tree' or 'free_tree'. |
iterated_t | The type that stores the sizes. |
iterator_t | The type of the iterator on a container containing values of type iterated_t. |
t | Input tree |
n | Number of nodes in the connected component of vertex x |
x | Node of the connected component for which we want to calculate the bidirectional sizes |
it | An iterator to the container that holds the size values. Such container must have size equal to twice the number of edges in the connected component of u and v. |
|
noexcept |
Calculate the dependencies and their span.
arrangement_t | Type of arrangement. |
t | Input tree. | |
arr | Input linear arrangement. | |
edge_with_max_pos_at | ||
cur_pos | Current position in the arrangement for which we calculate the dependencies. | |
[out] | flux | The flux at this position. |
[out] | cur_deps | The dependencies crossing this position. |
|
nodiscardnoexcept |
Calculates the level signature of an arrangement of a graph.
t | Level signature type. |
graph_t | Type of graph. |
g | Input graph. |
arr | Input arrangement. |
|
noexcept |
Calculates the level signature of an arrangement of a graph.
t | Level signature type. |
graph_t | Type of graph. |
g | Input graph. | |
arr | Input arrangement. | |
[out] | L | Level signature of the arrangement of the input graph. |
|
inlinenodiscardnoexcept |
Calculates the weight of a set of dependencies in a flux.
dependencies | Input dependencies. |
ug | Input undirected graph. |
|
nodiscardnoexcept |
Calculates the centroid and the corresponding rooted adjacency list.
t | Treer type. |
t | Input tree. | |
x | Node belonging to a connected component whose centroid we want. | |
[out] | L | Adjacency list-like data structure. \(L[u]\) is a list of pairs \((v, s_u(v))\) where \(v\) is a neighbour (with respect to a fictional root taken to be a centroidal vertex of the tree) of \(u\) and \(n_u(v)=|V(T^u_v)|\) is the size of the subtree \(T^u_v\) in vertices. |
|
nodiscardnoexcept |
Find errors in a treebank file.
decide | When true, return a value as soon as an error is found. |
treebank_filename | Name of the treebank file. |
|
nodiscardnoexcept |
Find errors in a treebank collection.
decide | When true, return a value as soon as an error is found. |
main_file_name | Name of the collection's main file. |
n_threads | Number of threads that this function can use. |
|
noexcept |
Classify a tree into one of the types graphs::tree_type.
tree_t | Type of tree. |
t | Input tree. | |
[out] | tree_types | A set of bits (or flags) each indicating whether or not t is of a certain tree type. |
|
inlinenodiscardnoexcept |
Finds an element within the sorted range [begin, end).
iterator_t | Iterator type. |
value_t | Value type. |
begin | Pointer at the first element of the range. |
end | Pointer at the last element of the range. |
size | The number of elements within the range. |
v | The value to search for. |
min_size | The minimum number of elements for the function to choose std::lower_bound over std::find. |
|
noexcept |
Completes the branchless path.
The first vertex of degree different from 2 is vertex u. And the next vertex in the sequence is vertex v.
tree_t | Type of tree. |
t | Input tree. |
u | First vertex of the path. |
v | Second vertex of the path. |
bfs | Breadth-First Search traversal object. |
res | Vector containing all branchless paths. |
p | Current branchless path. |
|
nodiscardnoexcept |
Fast tree non-isomorphism test.
tree_t | Tree type. |
t1 | One tree. |
t2 | Another tree. |
|
nodiscardnoexcept |
Calculates the centroid of a tree.
See Centre and centroid of a tree for details on what the centroid of a tree is.
If subtree sizes are to be returned, they come in an array of size the number of vertices of the tree.
mode | Indicates the value to be returned by this function. If:
|
tree_t | Type of tree. |
t | Input tree. |
x | Node belonging to a connected component whose centroid we want. |
|
inlinenodiscardnoexcept |
Returns true if, and only if, the graph has cycles.
g | Input graph. |
u | Node of the directed graph |
visited | For each node, has it been visited? |
in_stack | For each node, is it in the recursion stack? |
|
nodiscardnoexcept |
Find errors in a head vector.
The head vector may correspond to the contents of a line in a treebank file.
decide | When true, return a value as soon as an error is found. |
hv | Input head vector. |
|
nodiscardnoexcept |
Find errors in a line of a treebank.
decide | When true, return a value as soon as an error is found. |
current_line | The line being analyzed. |
|
inlinenodiscardnoexcept |
Finds an element within the sorted range [begin, end).
iterator_t | Iterator type. |
value_t | Value type. |
begin | Pointer at the first element of the range. |
end | Pointer at the last element of the range. |
size | The number of elements within the range. |
v | The value to search for. |
min_size | The minimum number of elements for the function to choose std::lower_bound over std::find. |
|
nodiscardnoexcept |
Converts an edge list into a graph.
An edge list is a list of pairs of indices, each index in the pair being different and in \([0,n-1]\)., where \(n\) is the number of vertices of the tree.
Methods lal::io::read_edge_list read an edge list from a file in disk.
edge_list | An edge list. |
normalize | Should the graph be normalized? |
check | In case the graph is not to be normalized, should we check whether it is nor not? |
|
nodiscardnoexcept |
Transforms a head vector in a directed graph.
graph_t | The type of graph. |
hv | The input head vector. |
normalize | Normalize the grpah or not? |
check | Check whether the graph is normalized or not? |
|
nodiscardnoexcept |
Converts a head vector into a tree.
tree_t | Type of input tree |
hv | Input head vector. |
normalize | Normalize the resulting tree. |
check | Check whether the constructed tree is normalized. |
|
nodiscardnoexcept |
Transforms a head vector in a tree.
Reads the head vector from a stream object.
tree_t | The type of tree. |
ss | Stream to read the head vector from. |
|
nodiscardnoexcept |
Converts the level sequence of a tree into a graph structure.
See lal::detail::from_level_sequence_to_tree for further details.
|
nodiscardnoexcept |
Converts the level sequence of a tree into a graph structure.
Examples of level sequences:
0 1 2 3 4 ... (n-1) n
0 1 2 2 2 .... 2 2 |------------| > (n-1) two's
tree_t | The type of tree. |
L | The level sequence, in preorder. |
n | Number of nodes of the tree. |
normalize | Should the tree be normalized? |
check | Should it be checked whether the tree is normalized or not? |
|
nodiscardnoexcept |
Converts the level sequence of a tree into a graph structure.
See lal::detail::from_level_sequence_to_tree for further details.
|
nodiscardnoexcept |
Converts the level sequence of a tree into a graph structure.
Examples of level sequences:
0 1 2 3 4 ... (n-1) n
0 1 2 2 2 .... 2 2 |------------| > (n-1) two's
tree_t | The type of tree. |
L | The level sequence, in preorder. |
n | Number of nodes of the tree. |
normalize | Should the tree be normalized? |
check | Should it be checked whether the tree is normalized or not? |
|
nodiscardnoexcept |
Converts the level sequence of a tree into a graph structure.
See lal::detail::from_level_sequence_to_tree for further details.
|
nodiscardnoexcept |
Converts the level sequence of a tree into a graph structure.
Examples of level sequences:
0 1 2 3 4 ... (n-1) n
0 1 2 2 2 .... 2 2 |------------| > (n-1) two's
tree_t | The type of tree. |
L | The level sequence, in preorder. |
n | Number of nodes of the tree. |
normalize | Should the tree be normalized? |
check | Should it be checked whether the tree is normalized or not? |
|
inlinenodiscardnoexcept |
Converts the Prüfer sequence of a labelled tree into a tree structure.
For details on Prüfer sequences, see [41].
seq | The Prufer sequence sequence. |
n | Number of nodes of the tree. |
normalize | Should the tree be normalized? |
check | Should it be checked whether the tree is normalized or not? |
|
inlinenodiscardnoexcept |
Converts the Prüfer sequence of a labelled tree into a tree structure.
For details on Prüfer sequences, see [41].
seq | The Prufer sequence sequence. |
n | Number of nodes of the tree. |
normalize | Should the tree be normalized? |
check | Should it be checked whether the tree is normalized or not? |
|
nodiscardnoexcept |
Constructs the head vector representation of a tree.
arrangement_t | Type of arrangement. |
t | Input free tree. |
r | Root of the tree. |
arr | Linear arrangement of the vertices. |
|
nodiscardnoexcept |
Constructs the head vector representation of a tree.
arrangement_t | Type of arrangement. |
t | Input rooted tree. |
arr | Linear arrangement of the vertices. |
|
inlinenoexcept |
Retrieves the neighbors of a node in an undirected graph as a list of 0-1 values.
Sets to 1 the positions in neighs that correspond to the nodes neighours of u.
g | Input graph. |
u | Input node. |
neighs | 0-1 list of neighbors of u in g. |
|
nodiscardnoexcept |
Retrieves the edges of a subtree.
get_subsizes | Should the result also keep the sizes of the subtrees? |
T | Input rooted tree. |
u | Root of the subtree. |
relabel | Relabel the vertices? If so, vertex 'u' is relabelled to 0 |
|
inlinenoexcept |
Calculate the size of every subtree of tree t.
The method starts calculating the sizes at node r. Since rooted trees have directed edges, starting at a node different from the tree's root may not calculate every subtree's size.
t | Input rooted tree. |
r | Start calculating sizes of subtrees at this node. |
sizes | The size of the subtree rooted at every reachable node from r. |
|
noexcept |
Calculate the size of every subtree of the tree t.
t | Input tree. |
u | Parent node (the first call should be an invalid value (e.g., n+1)). |
v | Next node in the exploration of the tree. |
sizes | The size of the subtree rooted at every reachable node from r. |
|
inlinenodiscardnoexcept |
Returns true if, and only if, the graph has DIRECTED cycles.
g | Input graph. |
|
inlinenodiscardnoexcept |
Returns true if, and only if, the graph has DIRECTED cycles.
g | Input graph. |
vis | Array of size 'n', where 'n' is the number of vertices of 'g'. |
in_stack | Array of size 'n', where 'n' is the number of vertices of 'g'. |
|
nodiscardnoexcept |
Returns true if, and only if, the graph has UNDIRECTED cycles.
In case the input graph is a directed graph, reverse edges are considered.
graph_t | Type of graph. |
g | Input graph. |
|
nodiscardnoexcept |
Returns true if, and only if, the graph has UNDIRECTED cycles.
In case the input graph is a directed graph, reverse edges are considered.
graph_t | Type of graph. |
g | Input graph. |
bfs | Breadth-First Search object. |
|
nodiscardnoexcept |
Proposition of right branching edges in a directed graph.
result_t | Type of return value. |
arrangement_t | Type of arrangement. |
g | Input directed graph. |
arr | Input linear arrangement. |
|
nodiscardnoexcept |
Is a given arrangement bipartite?
See Types of arrangements for details on bipartite arrangements.
If the input arrangement is empty then the identity arrangement \(\pi_I\) is used.
arrangement_t | Type of arrangement. |
g | Input graph. |
arr | Input linear arrangement. |
|
nodiscardnoexcept |
Is a given arrangement bipartite?
See Types of arrangements for details on bipartite arrangements.
If the input arrangement is empty then the identity arrangement \(\pi_I\) is used.
arrangement_t | Type of arrangement. |
c | Coloring of a bipartite graph. |
arr | Input linear arrangement. |
|
nodiscardnoexcept |
Is the input graph a tree?
By definition, an undirected graph is a tree if it does not contain cycles and has one single connected component. Note that isloated nodes count as single connected components. Directed graphs are allowed.
g | Input graph. |
|
inlinenodiscardnoexcept |
Returns true if the level sequence follows that of a maximum arrangement.
Checks whether or not the level signature is non-increasing, that is, whether the sequence of level values (in a per position distribution) is non-increasing.
This is a necessary condition for an arrangement to be maximum, as shown in [18] [39] and [7].
When the level signature is defined on a 'per position' basis, the arrangement is not needed.
t | Level signature type. |
graph_t | Type of graph. |
g | Input graph. |
arr | Input arrangement. |
levels | signature of the arrangement. |
|
nodiscardnoexcept |
Returns whether the number of crossings is less than a given constant.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
graph_t | Type of graph. |
g | Input graph. |
arr | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
nodiscardnoexcept |
Returns whether the number of crossings is less than a given constant.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. To each arrangement corresponds only one upper bound.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
upper_bounds | List of constants (each an upper bound). |
|
nodiscardnoexcept |
Returns whether the number of crossings is less than a given constant.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. The upper bound upper_bound is applied to all linear arrangements.
graph_t | Type of graph. |
g | Input graph. |
arrs | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. The upper bound upper_bound is applied to all linear arrangements.
graph_t | Type of graph. |
g | Input graph. |
arr | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. To each arrangement corresponds only one upper bound.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
upper_bounds | List of constants (each an upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. To each arrangement corresponds only one upper bound.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
graph_t | Type of graph. |
g | Input graph. |
arr | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. To each arrangement corresponds only one upper bound.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
upper_bounds | List of constants (each an upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. The upper bound upper_bound is applied to all linear arrangements.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
graph_t | Type of graph. |
g | Input graph. |
arr | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. To each arrangement corresponds only one upper bound.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
upper_bounds | List of constants (each an upper bound). |
|
nodiscardnoexcept |
Fast calculation of \(C\) if it is less than or equal to an upper bound.
Given a graph \(G\) and a linear arrangements \(\pi\) of its nodes, returns the number of edge crossings \(C_{\pi}(G)\) if it is less than or equal to the given upper bound constant \(u\). In case the number of crossings is greater, returns a value strictly larger than the upper bound.
This is applied to every linear arrangement in pi. The upper bound upper_bound is applied to all linear arrangements.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
upper_bound | Constant (upper bound). |
|
inlinenodiscardnoexcept |
Is a node reachable from another?
g | Input graph. |
source | Node where the search starts at. |
target | The node we want to know whether it is reachable from source or not. |
|
nodiscardnoexcept |
Is a given arrangement projective?
See Types of arrangements for details on projective arrangements.
If the input arrangement is empty then the identity arrangement \(\pi_I\) is used.
arrangement_t | Type of arrangement. |
rt | Input rooted tree |
arr | Input linear arrangement. |
|
nodiscardnoexcept |
Is the root of a rooted tree covered in a given arrangement?
See Properties that can be defined in linear arrangements for details on vertex covering in an arrangement.
If the input arrangement is empty then the identity arrangement \(\pi_I\) is used.
arrangement_t | Type of arrangement. |
rt | Input rooted tree |
arr | Input linear arrangement. |
|
nodiscardnoexcept |
Returns whether or not the input vertex is a thistle vertex.
t | Level signature type |
graph_t | Type of graph. |
g | Input graph. |
arr | Input arrangement. |
levels | Level signature of the arrangement. |
u | Vertex to check. |
|
noexcept |
Make an arrangement using permutations.
container | Object containing the permutations. |
T | Input rooted tree. | |
parent | Parent of node u. | |
u | Root of the current subtree. | |
data | The permutations used to construct the arrangement. | |
[out] | pos | Current position in the arrangement. |
[out] | arr | Arrangement constructed. |
|
nodiscardnoexcept |
Make an arrangement using permutations.
container | Object containing the permutations. |
T | Input rooted tree. |
root | Node used as root. |
data | The permutations to construct the arrangement from. |
|
nodiscardnoexcept |
Make an arrangement using permutations.
container | Object containing the permutations. |
T | Input rooted tree. |
data | The permutations to construct the arrangement from. |
|
noexcept |
Make an arrangement using permutations.
container | Object containing the permutations. |
T | Input rooted tree. | |
r | Root of the current subtree. | |
data | The permutations used to construct the arrangement. | |
[out] | pos | Current position in the arrangement. |
[out] | arr | Arrangement constructed. |
|
nodiscardconstexprnoexcept |
Make an array with the values given as parameters of the template.
T | Type of the array |
ARGS | List of values to be stored in the array. |
|
nodiscardconstexprnoexcept |
Returns an array initialized at a given value.
T | Type of the array's elements. |
array_size | Size of the array. |
value_to_fill_with | The value to fill the array with. |
|
nodiscardconstexprnoexcept |
Implementation of lal::detail::make_array_with_value.
Function used by lal::detail::make_array_with_value().
T | Type of the value. |
size | Size of the array. |
v | Value to use. |
I | Index sequence. |
|
nodiscardnoexcept |
Average sum of edge lengths in a graph.
result_t | Type of return value. |
graph_t | Type of graph. |
arrangement_t | Type of arrangement. |
g | Input directed graph. |
arr | Input linear arrangement. |
|
nodiscardnoexcept |
Mirrors a level signature.
level_signature_t | Level signature type. |
L | Input level signature. |
|
inlinenoexcept |
Rational-Rational division.
Divide a rational \(r_1\) by another rational \(r_2\).
[out] | num | The rational to be divided by \(k\). Result is \(r_1 := r_1/r_2\). |
[in] | den | The rational that divides the rational. |
|
inlinenoexcept |
Rational-Integer division.
Divide a rational \(r\) by an integer \(k\).
[out] | r | The rational to be divided by \(k\). Result is \(r := r/k\). |
[in] | k | The integer that divides the rational. |
|
inlinenoexcept |
Computes the exponentiation of a big integer to another big integer.
Fast exponentiation algorithm.
This function has, as an exception, its output parameter as its first parameter.
[out] | r | Result. \(r = b^e\). |
[in] | b | Base. |
[in] | e | Exponent. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arr | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arr | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arr | Linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arr | A linear arrangement of the nodes. When omitted, \(\pi_I\) is used. |
|
nodiscardnoexcept |
Is the number of crossings in the linear arrangement less than a constant?
Given a graph, and a linear arrangement of its nodes, computes by brute force the number of edges that cross in such linear arrangement. If the arrangement is not specified, the identity arrangement is used.
graph_t | Type of graph. |
g | Input graph. |
arrs | List of \(k\) linear arrangements of the nodes \(\Pi = \{\pi_i\}_{i=1}^k\). When one is omitted, \(\pi_I\) is used. |
|
inlinenodiscardnoexcept |
Returns true if no two adjacent vertices (in the graph) have the same level value.
Checks that no edge \(uv\in E(G)\) is such that \(l_{\pi}(u) = l_{\pi}(v)\). This is a necessary condition for an arrangement to be maximum (in sum of edge lengths), as shown in [18] [39] and [7].
When the level signature is defined on a 'per vertex' basis, the arrangement is not needed.
t | Level signature type. |
graph_t | Type of graph. |
g | Input graph. |
arr | Input arrangement. |
levels | signature of the arrangement. |
|
inlinenodiscardnoexcept |
Returns true if none of the vertices in the antennas of the graph is a thistle.
Checks that no vertex in any antenna of the tree is a thistle vertex in the input arrangement. This is a necessary condition for an arrangement to be maximum (in sum of edge lengths), as shown in [7].
When the level signature is defined on a 'per vertex' basis, the arrangement is not needed.
t | Level signature type. |
graph_t | Type of graph. |
g | Input graph. |
arr | Input arrangement. |
levels | signature of the arrangement. |
bps | All Branchless Paths of the tree. |
|
inlinenoexcept |
Power operation.
Raise a rational value \(r\) to a certain power \(p\).
[out] | r | Rational value. Result is \(r = r^p\). |
[in] | p | Exponent. |
|
inlinenoexcept |
Power operation.
Raise a rational value \(r\) to a certain power \(p\).
[out] | r | Rational value. Result is \(r = r^p\). |
[in] | p | Exponent. |
|
inlinenodiscardnoexcept |
Predicted number of crossings based on the sum of edge lengths.
See [22] for further details. This functions implements \(E_2[C]\).
result_t | Type of the return value. |
graph_t | Type of graph. |
arrangement_t | Type of arrangement. |
g | Input graph. |
arr | Input arrangement. |
|
nodiscardnoexcept |
Calculate the centre of the connected component that has node x.
See Centre and centroid of a tree for details on what the centre of a tree is.
A graph of type lal::graphs::tree may lack some edges tree so it has several connected components. Vertex x belongs to one of these connected components.
This method finds the central nodes of the connected components node 'x' belongs to.
tree_t | type of tree. |
t | Input tree. |
X | Input node. |
|
nodiscardnoexcept |
Calculate the centroid of the connected component that has node x.
For details on the parameters and return value see documentation of the function above.
tree_t | Type of tree. |
t | Input tree |
x | Node belonging to a connected component whose centroid we want. |
|
nodiscardnoexcept |
Number of right branching edges in a directed graph.
arrangement_t | Type of arrangement. |
g | Input directed graph. |
arr | Input linear arrangement. |
|
nodiscardnoexcept |
Enumerate the set of edges of the input graph g.
g | Input graph. |
|
nodiscardnoexcept |
Enumerate the set of pairs of independent edges of the input graph g.
g | Input graph. |
qs | Total amount of pairs of independent edges. |
|
nodiscardnoexcept |
Sum of edge lengths in a graph.
graph_t | Type of graph. |
arrangement_t | Type of arrangement. |
g | Input directed graph. |
arr | Input linear arrangement. |
|
nodiscardconstexprnoexcept |
Converts a value of the enumeration lal::linarr::syntactic_dependency_tree_type into a string.
|
nodiscardnoexcept |
Calculate the diameter of a tree.
See Diameter of a tree for details on the definition of the diameter of a tree.
The diameter of the connected component to which node x belongs to.
tree_t | Type of tree. |
t | Input tree. |
x | Input node. |
|
noexcept |
Update the Union-Find data structure after the addition of an edge.
This function updates the Union-Find data structure of a tree after the addition of an edge between vertices u and v.
tree_t | Type of input tree. A derived class of lal::graphs::free_tree or a derived class of lal::graphs::rooted_tree. |
t | Input tree |
u | Node |
v | Node |
root_of | Pointer to an array where root_of[s] = t if the root of the connected component of s is t |
root_size | Sizes of each connected component. |
|
noexcept |
Update the Union-Find data structure after the addition of several edges.
tree_t | Type of tree |
t | Input tree |
edges | Edges added to the tree |
root_of | Pointer to an array where root_of[s] = t if the root of the connected component of s is t |
root_size | Sizes of each connected component. |
|
noexcept |
Update the Union-Find data structure after several edges have been operated in bulk.
tree_t | Type of tree |
t | Input tree |
root_of | Pointer to an array where root_of[s] = t if the root of the connected component of s is t |
root_size | Sizes of each connected component. |
|
noexcept |
Updates Union-Find after the removal of an edge.
This function updates the Union-Find data structure of a tree after the removal of the edge between vertices u and v.
tree_t | Type of input tree. A derived class of lal::graphs::free_tree or a derived class of lal::graphs::rooted_tree. |
t | Input tree |
u | Node |
v | Node |
root_of | Pointer to an array where root_of[s] = t if the root of the connected component of s is t |
root_size | Sizes of each connected component. |
|
noexcept |
Update the Union-Find data structure after the addition of several edges.
tree_t | Type of input tree. A derived class of lal::graphs::free_tree or a derived class of lal::graphs::rooted_tree. |
t | Input tree |
edges | Edges added to the tree |
root_of | Pointer to an array where root_of[s] = t if the root of the connected component of s is t |
root_size | Sizes of each connected component. |
|
noexcept |
Update Union-Find after the removal of a vertex.
This function updates the Union-Find data structure of a tree prior to the removal of the edge (u,v).
In particular, it updates the information associated to the vertices found in the direction (u,v).
tree_t | Type of input tree. A derived class of lal::graphs::free_tree or a derived class of lal::graphs::rooted_tree. |
bfs | Breadth-First Search object. |
v | Node to be removed. |
root_of | Pointer to an array where root_of[s] = t if the root of the connected component of s is t |
root_size | Sizes of each connected component. |
|
noexcept |
Update Union-Find after a vertex removal.
This function updates the Union-Find data structure of a tree prior to the removal of the edge (u,v).
In particular, it updates the information associated to the vertices found in the direction (u,v).
tree_t | Type of input tree. A derived class of lal::graphs::free_tree or a derived class of lal::graphs::rooted_tree. |
t | Input tree. |
u | Node to be removed. |
root_of | Pointer to an array where root_of[s] = t if the root of the connected component of s is t |
root_size | Sizes of each connected component. |