LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
Dmin.hpp
1/*********************************************************************
2 *
3 * Linear Arrangement Library - A library that implements a collection
4 * algorithms for linear arrangments of graphs.
5 *
6 * Copyright (C) 2019
7 *
8 * This file is part of Linear Arrangement Library. To see the full code
9 * visit the webpage:
10 * https://github.com/lluisalemanypuig/linear-arrangement-library.git
11 *
12 * Linear Arrangement Library is free software: you can redistribute it
13 * and/or modify it under the terms of the GNU Affero General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * Linear Arrangement Library is distributed in the hope that it will be
18 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public License
23 * along with Linear Arrangement Library. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * Contact:
26 *
27 * LluĂ­s Alemany Puig (lalemany@cs.upc.edu)
28 * LARCA (Laboratory for Relational Algorithmics, Complexity and Learning)
29 * CQL (Complexity and Quantitative Linguistics Lab)
30 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
31 * Webpage: https://cqllab.upc.edu/people/lalemany/
32 *
33 * Ramon Ferrer i Cancho (rferrericancho@cs.upc.edu)
34 * LARCA (Laboratory for Relational Algorithmics, Complexity and Learning)
35 * CQL (Complexity and Quantitative Linguistics Lab)
36 * Office S124, Omega building
37 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
38 * Webpage: https://cqllab.upc.edu/people/rferrericancho/
39 *
40 ********************************************************************/
41
42#pragma once
43
44#include <lal/graphs/rooted_tree.hpp>
45#include <lal/graphs/free_tree.hpp>
46
47namespace lal {
48namespace internal {
49
50/*
51 * @brief Algorithm to calculate unconstrained optimal linearization of free trees.
52 *
53 * Computes an unconstrained optimal linear arrangement of a free tree and
54 * the value of its cost, i.e., the sum of the lengths of the edges.
55 *
56 * This function implements Yossi Shiloach's algorithm published in \cite Shiloach1979a.
57 * The implementation of this algorithm uses the corrections published
58 * in \cite Esteban2017a.
59 *
60 * @pre The object must be a tree (see @ref lal::graphs::rooted_tree::is_rooted_tree).
61 */
62std::pair<uint32_t, linear_arrangement> Dmin_Unconstrained_YS
63(const graphs::free_tree& t) noexcept;
64
65/*
66 * @brief Algorithm to calculate unconstrained optimal linearization of free trees.
67 *
68 * Computes an unconstrained optimal linear arrangement of a free tree and
69 * the value of its cost, i.e., the sum of the lengths of the edges.
70 *
71 * This function implements Fan Chung's algorithm published in \cite Chung1984a.
72 *
73 * @pre The object must be a tree (see @ref lal::graphs::rooted_tree::is_rooted_tree).
74 */
75std::pair<uint32_t, linear_arrangement> Dmin_Unconstrained_FC
76(const graphs::free_tree& t) noexcept;
77
78/*
79 * @brief Algorithm to calculate optimal planar arrangements of free trees.
80 *
81 * Computes an optimal planar linear arrangement for free trees.
82 * A planar linear arrangement is an arrangement in which there are
83 * no edge crossings.
84 *
85 * This function implements the algorithm published in \cite Alemany2021a.
86 *
87 * Computes an optimal planar linear arrangement for free trees. A planar linear
88 * arrangement is an arrangement in which there are no edge crossings. This problem
89 * was originally tackled by Iordanskii \cite Iordanskii1987a and later by Hochberg
90 * and Stallmann \cite Hochberg2003a. See \cite Alemany2021a for a review.
91 *
92 * @param t Input tree.
93 * @pre The object @e t must be a tree (see @ref lal::graphs::free_tree::is_tree).
94 */
95std::pair<uint32_t, linear_arrangement> Dmin_Planar
96(const graphs::free_tree& t) noexcept;
97
98/*
99 * @brief Algorithm to calculate optimal projective arrangements of rooted trees.
100 *
101 * Computes an optimal projective linear arrangement for rooted trees.
102 * A projective linear arrangement is an arrangement in which there are
103 * no edge crossings and the root is not covered by any edge.
104 *
105 * This function implements the algorithm in \cite Alemany2021a. A non-linear
106 * time algorithm to solve this problem was oulined in \cite Gildea2007a.
107 *
108 * @param t Input rooted tree.
109 * @pre The object @e t must be a valid rooted tree (see
110 * @ref lal::graphs::rooted_tree::is_rooted_tree).
111 */
112std::pair<uint32_t, linear_arrangement> Dmin_Projective
113(const graphs::rooted_tree& t) noexcept;
114
115/*
116 * t: the rooted tree.
117 * M: adjacency matrix of the tree with extra information: for each vertex,
118 * attach an integer that represents the size of the subtree rooted
119 * at that vertex. Each adjacency list is sorted INCREASINGLY by that size.
120 * r: the vertex root of the subtree whose interval is to be made
121 * data: the interval of every vertex.
122 * data[v][p] = u <-> vertex 'u' is at position 'p' of vertex 'v's interval
123 *
124 * Returns the sum of the length of the edges incident to vertex 'r' plus
125 * the length of the anchor of the edge from 'r' to its parent. Such length
126 * is defined as the number of vertices to the left of 'r' if 'r_place'
127 * is RIGHT_PLACE, or as the number of vertices to the right of 'r' if
128 * 'r_place' is LEFT_PLACE.
129 *
130 * See implementation for all details of this method.
131 */
132uint32_t Dmin_Pr__optimal_interval_of(
133 uint32_t n,
134 const std::vector<std::vector<std::pair<lal::node,uint32_t>>>& M,
135 node r,
137) noexcept;
138
139} // -- namespace internal
140} // -- namespace lal
Main namespace of the library.
Definition definitions.hpp:48
uint32_t node
Node type.
Definition definitions.hpp:51
std::vector< position > linear_arrangement
A linear arrangement of the nodes of a graph.
Definition definitions.hpp:72