Abstract
A monotone drawing of a graph G is a straight-line drawing of G such that every pair of vertices is connected by a path that is monotone with respect to some direction.
Trees, as a special class of graphs, have been the focus of several papers and, recently, He and HeĀ [6] showed how to produce a monotone drawing of an arbitrary n-vertex tree that is contained in a \(12n \times 12n\) grid.
In this paper, we present a simple algorithm that constructs for each arbitrary tree a monotone drawing on a grid of size at most \(n \times n\).
The work of Prof. Symvonis was supported by the iRead H2020 research grant (No. 731724).
You have full access to this open access chapter, Download conference paper PDF
Similar content being viewed by others
1 Introduction
A straight-line drawing \(\varGamma \) of a graph G is a mapping of each vertex to a distinct point on the plane and of each edge to a straight-line segment between the vertices. A path \(P=\{p_0,p_1,\ldots ,p_n\}\) is monotone if there exists a line l such that the projections of the vertices of P on l appear on l in the same order as on P. A straight-line drawing \(\varGamma \) of a graph G is monotone, if a monotone path connects every pair of vertices.
Monotone graph drawing has gained the recent attention of researchers and several interesting results have appeared. Given a planar fixed embedding of a planar graph G, a planar monotone drawing of G can be constructed, but at the cost of some bends on some edgesĀ [2]. In the variable embedding setting, we can construct a planar monotone drawing of any planar graph without any bendsĀ [8].
One way to find a monotone drawing of a graph is to simply find a monotone drawing of one of its spanning trees. For that reason, the problem of finding monotone drawings of trees has been the subject of several recent papers, starting from the work by Angelini et al.Ā [1] which introduced monotone graph drawings. Angelini et al.Ā [1] provided two algorithms that used ideas from number theory and more specifically Stern-Brocot treesĀ [3, 11],Ā [4, Sect.Ā 4.5]. The first algorithm used a grid of size \(O(n^{1.6}) \times O(n^{1.6})\) (BFS-based algorithm) while the second one used a grid of size \(O(n) \times O(n^2)\) (DFS-based algorithm). Later, Kindermann et al.Ā [9] provided an algorithm based on Farey sequence (seeĀ [4, Sect.Ā 4.5]) that used a grid of size \(O(n^{1.5}) \times O(n^{1.5})\). He and HeĀ [7] gave an algorithm based on Farey sequence and reduced the required grid size to \(O(n^{1.205}) \times O(n^{1.205})\), which was the first result that used less than \(O(n^3)\) area. Recently, He and HeĀ [5] firstly reduced the grid size for a monotone tree drawing to \(O(n \log (n)) \times O(n \log (n))\) and, in a sequel paper, to \(O(n) \times O(n)\)Ā [6]. Their monotone tree drawing uses a grid of size at most \(12n \times 12n\) which turns out to be asymptotically optimal as there exist trees which require at least \({n\over 12} \times {n \over 12}\) areaĀ [6].
Our Contribution: We provide a simple algorithm that given any n-vertex tree T, outputs a monotone drawing of T on a grid of size \(n \times n\). Example drawings of our algorithm appear at Figs.Ā 1, 2, 3, 4 and 5. Our algorithm does not employ number theory techniques but a rather simple weighting method and some simple facts from geometry that can be more analytically expressed. Due to space limitation, some proofs appear in the arXiv version of the paper [10].
2 Definitions and Preliminaries
Let \(\varGamma \) be a drawing of a graph G and (u,Ā v) be an edge from vertex u to vertex v in G. The slope of edge (u,Ā v), denoted by slope(u,Ā v), is the angle spanned by a counter-clockwise rotation that brings a horizontal half-line starting at u and directed towards increasing x-coordinates to coincide with the half-line starting at u and passing through v. We consider slopes that are equivalent modulo \(2\pi \) as the same slope. Observe that \(slope(u,v)=slope(v,u) - \pi \).
Let T be a tree rooted at a node r. Denote by \(T_u\) the subtree of T rooted at a node u. By \(|T_u|\) we denote the number of vertices of \(T_u\). In the rest of the paper, we assume that all tree edges are directed away from the root.
In order to simplify the description of our algorithm, we extend the definition of slope-disjoint tree drawings given by Angelini et al.Ā [1]. More specifically, a tree drawing \(\varGamma \) of a rooted tree T is called a non-strictly slope-disjoint drawing if the following conditions hold:
-
1.
For every node \(u \in T\), there exist two angles \(a_1(u)\) and \(a_2(u)\), with \(0 \varvec{\le } a_1(u)<a_2(u)\varvec{\le } \pi \) such that for every edge e that is either in \(T_u\) or enters u from its parent, it holds that \(a_1(u)<slope(e)<a_2(u)\).
-
2.
For every two nodes \(u, v \in T\) such that v is a child of u, it holds that \(a_1(u) \varvec{\le } a_1(v) < a_2(v) \varvec{\le } a_2(u)\).
-
3.
For every two nodes \(u_1, u_2\) with the same parent, it holds that either \(a_1(u_1)< a_2(u_1) \varvec{\le } a_1(u_2) < a_2(u_2)\) or \(a_1(u_2)< a_2(u_2) \varvec{\le } a_1(u_1) < a_2(u_1)\).
The idea behind the original definition of slope-disjoint tree drawings is that all edges in the subtree \(T_u\) as well as the edge entering u from its parent will have slopes that strictly fall within the angle range \(\left( a_1(u), a_2(u)\right) \) defined for vertex u. \(\left( a_1(u), a_2(u)\right) \) is called the angle range of u with \(a_1(u)\) and \(a_2(u)\) being its boundaries. In our extended definition, we allow for angle ranges of adjacent vertices (parent-child relationship) or sibling vertices (children of the same parent) to share angle range boundaries. Note that replacing the ā\(\le \)ā symbols in our definition by the ā<ā symbol gives us the original definition of Angelini et al.Ā [1] for the slope disjoint tree drawings.
Lemma 1
Every non-strictly slope-disjoint drawing of a tree T is also a slope-disjoint drawing.
Theorem 1
Ā [1] Every slope-disjoint drawing of a tree is monotone.
Theorem 2
Every non-strictly slope-disjoint drawing of a tree is monotone.
Based on geometry, we now prove that it is always possible to identify points on a grid that satisfy several properties with respect to their location.
Lemma 2
[See Fig.Ā 6]. Consider two angles \(\theta _1\), \(\theta _2\) with \(0 \le \theta _1 < \theta _2 \le \frac{\pi }{4}\), and let \(d=\lceil \frac{1}{\theta _2-\theta _1}\rceil \). Then, edge e connecting the origin (0,Ā 0) to point \(p=(d, \lfloor tan(\theta _1)d +1\rfloor )\) satisfies \(\theta _1< slope(e) < \theta _2\).
Lemma 3
[See Fig.Ā 7]. Consider angles \(\theta _1\), \(\theta _2\) with \(0 \le \theta _1 < \theta _2 \le \frac{\pi }{2}\) and let \(d=\lceil \frac{1}{\theta _2-\theta _1}\rceil \). Then, a grid point p such that the edge e that connects the origin (0,Ā 0) to p satisfies \(\theta _1< slope(e) < \theta _2\), can be identified as follows:
Moreover, if \(p=(x,y)\) is the identified point, it also holds that:
3 Monotone Tree Drawing on an \(n \times n\) Grid
Our tree drawing algorithm will produce a non-strictly slope-disjoint tree drawing which, by TheoremĀ 2, is monotone. We make the assumption that the given tree is rooted, otherwise, it can be rooted at any arbitrary node. In order to describe a non-strictly slope-disjoint tree drawing, we need to identify for each vertex u of the tree a grid point to draw u as well as to assign to it two angles \(a_1(u)\), \(a_2(u)\), with \(a_2(u) > a_1(u)\). For every tree vertex, the identified grid point and the two angles should be such that the three properties of the non-strictly slope-disjoint drawing are satisfied.
The basic idea behind our algorithm is to split in a balanced way the angle range \(\left( a_1(u), a_2(u)\right) \) of vertex u to its children based on the size of the subtrees rooted at them. The following lemma formalizes this idea.
Lemma 4
Let u be a node of the rooted tree T such that we already have assigned values for \(a_1(u)\) and \(a_2(u)\), with \(a_1(u) < a_2(u)\). Let \(u_1, u_2, \ldots , u_m,~m\ge 1\), be the children of u in T. Then, the following assignment of \(a_1\), \(a_2\) for the children of u satisfies Property-2 and Property-3 of the non-strictly slope disjoint drawing:
Observation 1
If a vertex u has only one child, say \(u_1\), then the angle assignment strategy of LemmaĀ 4 assigns \(a_1(u_1)=a_1(u)\) and \(a_2(u_1)=a_2(u)\), which means that the child āinheritsā the angle-range of its parent.
AlgorithmĀ 1 describes our monotone tree drawing algorithm. It consists of three steps: Procedure AssignAngles which assigns angle-ranges to the vertices of the tree according to LemmaĀ 4, Procedure DrawVertices which assigns each tree vertex to a grid point according to LemmaĀ 3 and Procedure BalancedTreeMonotoneDraw which assigns the root to point (0,Ā 0) with angle-range \(\left( 0,\frac{\pi }{2} \right) \) and initiates the drawing of the tree.
Lemma 5
The drawing produced by AlgorithmĀ 1 is monotone.
Proof
The angle-range assignment satisfies Property-2 and Property-3 of the non-strictly slope disjoint drawing as proved in LemmaĀ 4. In addition, the assignment of the vertices to grid points satisfies Property-1 of the non-strictly slope disjoint drawing as proved in LemmaĀ 3. Thus, the produced drawing by AlgorithmĀ 1 is non-strictly slope disjoint and, by TheoremĀ 2, it is monotone. Ā Ā Ā \(\square \)
It remains to establish a bound on the grid size required by AlgorithmĀ 1. Our proof will use induction on the number of tree vertices having more than one child. The following lemma will be used as the basis of our induction.
Lemma 6
Let T be an n-vertex rooted tree in which all vertices have at most one child, i.e., T is a path rooted at one of its endpoints. Then, AlgorithmĀ 1 draws T in the diagonal of an \(n \times n\) grid.
Lemma 7
Let T be a rooted tree in which \(k>0\) of its vertices have at least two children. Let u be a vertex with at least two children and, moreover, every other vertex in \(T_u\) has at most one child. Let \(T^\prime \) be the tree derived by replacing (in T) the subtree \(T_u\) by a path of length \(|T_u|\). Then, the size of the grid which AlgorithmĀ 1 uses in the worst case for the drawing of T is smaller or equal to the size of the grid it uses in the worst case for the drawing of \(T^\prime \).
Proof
Let u be a vertex as the one stated in the lemma, i.e., in \(T_u\), u is the only vertex having at least two children. Let \(u_1, u_2, \ldots u_m, ~m \ge 2\), be the children of u, and let \(T_{u_i}\) be the subtree rooted at \(u_i\). Note that each \(T_{u_i}\) is a path. From ObservationĀ 1, we recall that for each node in \(T_{u_i}\), the assigned values for \(a_1\) and \(a_2\) by AlgorithmĀ 1 will be the same as \(a_1(u_i)\) and \(a_2(u_i)\). Let \(\phi (u) = a_2(u) - a_1(u)\). We consider two subcases based on whether \(arctan(\frac{1}{2}) \ge \phi (u)\) or not.
Ā
- Case-1: \(arctan(\frac{1}{2}) \ge \phi (u)\).:
-
Since AlgorithmĀ 1 performs its angle-range assignment based on LemmaĀ 4, for each child of u we have that \(\phi (u_i)=a_2(u_i) - a_1(u_i) = \frac{|T_{u_i}|}{|T_u|-1}\phi (u)\). Observe that it also holds that \(\phi (u_i) \le arctan(\frac{1}{2})\). A node in \(T_{u_i}\) is drawn, based on LemmaĀ 3 where \(\theta _1 \leftarrow a_1(u_i)\) and \(\theta _2 \leftarrow a_2(u_i)\), in a grid of length at most \(\frac{1}{\theta _2 (u_i) - \theta _1 (u_i)}+1\) if its parent is considered to be drawn at the origin. So, the length of the total grid that is used for the drawing of path \(T_{u_i}\) is at most: \(|T_{u_i}|(\frac{1}{\theta _2 (u_i) - \theta _1 (u_i)}+1)\) \(=|T_{u_i}| \frac{1}{\frac{|T_{u_i}|}{|T_u|-1}\phi (u)}+|T_{u_i}|\) \(=\frac{|T_u|-1}{\phi (u)} + |T_{u_i}|\) \(\le \frac{|T_u|-1}{\phi (u)} + |T_u|-1\) \(=(|T_u|-1)(\frac{1}{\phi (u)} + 1)\). The last term is the maximum grid length dictated by LemmaĀ 3 for the drawing of a path of size \(|T_{u}|\) with \(\theta _1 \leftarrow a_1(u)\) and \(\theta _2 \leftarrow a_2(u)\). Note also that in AlgorithmĀ 1 the largest grid devoted to any of \(T_{u_i}, 1\le i \le m\), determines the grid size of the drawing of \(T_u\) since the subtrees rooted at children of u are drawn completely inside non-overlapping (but possibly touching) angular sectors. The above statement holds because all the grids that will be used for the subtrees have the same origin (u) and all angular sectors lies in the first quadrant since AlgorithmĀ 1 assigns root with angle-range \(\left( 0, \frac{\pi }{2}\right) \). So, the grid size that is used in the worst case for the drawing of \(T_u\) by AlgorithmĀ 1 is smaller or equal to that used by it in the worst case for the drawing of a path of length \(|T_u|\). Thus, the size of the grid which AlgorithmĀ 1 uses in the worst case for the drawing of T is smaller or equal to the size of the grid it uses in the worst case for the drawing of \(T^\prime \).
- Case-2: \(\phi (u) > arctan(\frac{1}{2})\).:
-
Let \(\phi (u_i)=a_2(u_i) - a_1(u_i), 1 \le i \le m\). We consider two subcases based on whether \(arctan(\frac{1}{2}) \ge \phi (u_i)\) or not. Ā
- Case-2a: \(arctan(\frac{1}{2}) \ge \phi (u_i)\).:
-
A node in \(T_{u_i}\) is drawn, based on LemmaĀ 3 where \(\theta _1 (u_1) \leftarrow a_1(u_i)\) and \(\theta _2 (u_i) \leftarrow a_2(u_i)\), in a grid of length at most \(\frac{1}{\phi (u_i)} + 1 < \frac{\pi }{2}\frac{1}{\phi (u_i)}\), assuming that its parent is drawn at the origin. The last inequality holds for \(\phi (u_i) \le \frac{\pi - 2}{2}\), and so it also holds for \(\phi (u_i) \le arctan(\frac{1}{2}) < \frac{\pi -2}{2}\). So, the maximum length of the total grid that is used for the drawing of path \(T_{u_i}\) is at most: \(|T_{u_i}|\frac{\pi }{2}\frac{1}{\phi (u_i)}= |T_{u_i}|\frac{\pi }{2} \frac{1}{\frac{|T_{u_i}|}{|T_u|-1}\phi (u)}= \frac{\pi }{2}\frac{|T_u|-1}{\phi (u)}\).
- Case-2b: \(\phi (u_i) > arctan(\frac{1}{2})\).:
-
A node in \(T_{u_i}\) is drawn, based on LemmaĀ 3 where \(\theta _1 (u_i) \leftarrow a_1(u_i)\) and \(\theta _2 (u_i) \leftarrow a_2(u_i)\), in a grid of length at most \(\frac{\pi }{2}*\frac{1}{\phi (u_i)}\), assuming that its parent is drawn at the origin. So, the maximum length of the total grid that is used for the drawing of path \(T_{u_i}\) is: \(|T_{u_i}|\frac{\pi }{2}\frac{1}{\phi (u_i)}= |T_{u_i}|\frac{\pi }{2} \frac{1}{\frac{|T_{u_i}|}{|T_u|-1}\phi (u)}= \frac{\pi }{2}\frac{|T_u|-1}{\phi (u)}\).
Ā The last term in both subcases is the maximum grid length dictated by LemmaĀ 3 for the drawing of a path of size \(|T_{u}|\) with \(\theta _1 \leftarrow a_1(u)\) and \(\theta _2 \leftarrow a_2(u)\) where \(\phi (u) > arctan(\frac{1}{2})\). So, the drawing of \(T_u\) uses in the worst case a grid length that is smaller or equal to that used in the worst case for the drawing of a path of length \(|T_u|\), when both drawings are done by AlgorithmĀ 1. Thus, AlgorithmĀ 1 uses in the worst case for the drawing of T a grid of size smaller or equal to the one used in the worst case for the drawing of \(T^\prime \).Ā Ā Ā \(\square \)
Ā
Theorem 3
Given a rooted Tree T, AlgorithmĀ 1 produces a monotone grid drawing using a grid of size at most \(n \times n\).
Proof
The monotonicity of the drawing follows directly from LemmaĀ 5. By repeatedly applying LemmaĀ 7, we get that in the worst case the drawing of T uses a grid length that is smaller or equal to the one used in the worst case for the drawing of a path of length |T|, when both drawings are done by AlgorithmĀ 1. By LemmaĀ 6, we get that the used grid is of size at most \(n \times n\). Ā Ā Ā \(\square \)
References
Angelini, P., Colasante, E., Di Battista, G., Frati, F., Patrignani, M.: Monotone drawings of graphs. J. Graph Algorithms Appl. 16(1), 5ā35 (2012)
Angelini, P., Didimo, W., Kobourov, S., Mchedlidze, T., Roselli, V., Symvonis, A., Wismath, S.: Monotone drawings of graphs with fixed embedding. Algorithmica 71(2), 233ā257 (2015)
Brocot, A.: Calcul des rouages par approximation, nouvelle methode. Revue Chronometrique 6, 186ā194 (1860)
Graham, R.L., Knuth, D.E., Patashnik, O.: Concrete Mathematics: A Foundation for Computer Science, 2nd edn. Addison-Wesley Longman Publishing Co. Inc., Boston (1994)
He, D., He, X.: Nearly optimal monotone drawing of trees. Theor. Comput. Sci. 654, 26ā32 (2016)
He, D., He, X.: Optimal monotone drawings of trees. CoRR abs/1604.03921 (2016)
He, X., He, D.: Compact monotone drawing of trees. In: Xu, D., Du, D., Du, D. (eds.) COCOON 2015. LNCS, vol. 9198, pp. 457ā468. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-21398-9_36
Hossain, M.I., Rahman, M.S.: Good spanning trees in graph drawing. Theor. Comput. Sci. 607, 149ā165 (2015)
Kindermann, P., Schulz, A., Spoerhase, J., Wolff, A.: On monotone drawings of trees. In: Duncan, C., Symvonis, A. (eds.) GD 2014. LNCS, vol. 8871, pp. 488ā500. Springer, Heidelberg (2014). https://doi.org/10.1007/978-3-662-45803-7_41
Oikonomou, A., Symvonis, A.: Simple compact monotone tree drawings. CoRR abs/1708.09653v2 (2017). http://arxiv.org/abs/1708.09653v2
Stern, M.: Ueber eine zahlentheoretische funktion. Journal fur die reine und angewandte Mathematik 55, 193ā220 (1858)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
Ā© 2018 Springer International Publishing AG
About this paper
Cite this paper
Oikonomou, A., Symvonis, A. (2018). Simple Compact Monotone Tree Drawings. In: Frati, F., Ma, KL. (eds) Graph Drawing and Network Visualization. GD 2017. Lecture Notes in Computer Science(), vol 10692. Springer, Cham. https://doi.org/10.1007/978-3-319-73915-1_26
Download citation
DOI: https://doi.org/10.1007/978-3-319-73915-1_26
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-73914-4
Online ISBN: 978-3-319-73915-1
eBook Packages: Computer ScienceComputer Science (R0)