# Simple Compact Monotone Tree Drawings

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 showed how to produce a monotone drawing of an arbitrary n-vertex tree that is contained in a 12n × 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 × n.

## Authors

• 2 publications
• 7 publications
• ### Drawing planar graphs with few segments on a polynomial grid

The visual complexity of a plane graph drawing is defined to be the numb...
03/20/2019 ∙ by Philipp Kindermann, et al. ∙ 0

• ### Plane Spanning Trees in Edge-Colored Simple Drawings of K_n

Károlyi, Pach, and Tóth proved that every 2-edge-colored straight-line d...
08/20/2020 ∙ by Oswin Aichholzer, et al. ∙ 0

• ### A better method to enforce monotonic constraints in regression and classification trees

In this report we present two new ways of enforcing monotone constraints...
11/02/2020 ∙ by Charles Auguste, et al. ∙ 0

• ### Notes on Monotone Recognition in Multi-Valued Grids

Implementation details of method of monotone recognition, based on parti...
01/24/2021 ∙ by Levon Aslanyan, et al. ∙ 0

• ### Searching by Heterogeneous Agents

In this work we introduce and study a pursuit-evasion game in which the ...
05/06/2021 ∙ by Dariusz Dereniowski, et al. ∙ 0

• ### Tree Drawings Revisited

We make progress on a number of open problems concerning the area requir...
03/19/2018 ∙ by Timothy M. Chan, et al. ∙ 0

• ### Generalized LR-drawings of trees

The LR-drawing-method is a method of drawing an ordered rooted binary tr...
05/14/2021 ∙ by Therese Biedl, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

A straight-line drawing 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 is monotone if there exists a line such that the projections of the vertices of on appear on in the same order as on . A straight-line drawing 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 , a planar monotone drawing of can be constructed, but at the cost of some bends on some edges (thus no longer a straight-line drawing) [2]. In the variable embedding setting, there exists 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 [11, 3][4, Sect. 4.5]. The first algorithm used a grid of size (BFS-based algorithm) while the second one used a grid of size (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 . He and He [7] gave an algorithm based on Farey sequence and reduced the required grid size to , which was the first result that used less than area. Recently, He and He [5] firstly reduced the grid size for a monotone tree drawing to and, in a sequel paper, to  [6]. Their monotone tree drawing uses a grid of size at most which turns out to be asymptotically optimal as there exist trees which require at least area [6].

Our Contribution:

All monotone tree drawing algorithms that have appeared in the literature consider rooted ordered trees and they draw them so that (i) the root of the tree is drawn at the origin of the drawing, (ii) the drawing is confined in the first quadrant, and (iii) the embedding of the tree is respected. In this paper, we provide a simple algorithm that has the exact same characteristics and, given an -vertex rooted tree , it outputs a monotone drawing of that fits on a grid. Despite its simplicity, our algorithm improves the result of He and He [6].

By relaxing the drawing restrictions we can achieve smaller drawing area. More specifically, by carefully selecting a new root for the tree, which we draw it at the origin, we can produce a “two-quadrants” drawing that fits in an grid. We note that the produced drawing respects the given embedding of the tree. By further relaxing this requirement, i.e., by allowing to change the order of the neighbors of a tree vertex around it, we can achieve a drawing of better aspect ratio and smaller area (compared to our algorithm). More specifically, we describe a “four-quandrants” algorithm that draws an -vertex tree on a grid of size at most .

The paper is organized as follows: Section 2 provides definitions and preliminary results. In Sections 3, 4 and 5 we present our one-, two- and four-quadrants algorithms, respectively. We conclude in Section 6. A preliminary version of this paper which included the one-quadrant algorithm for monotone tree drawings was presented in [10].

## 2 Definitions and Preliminaries

Let be a drawing of a graph and be an edge from vertex to vertex in . The slope of edge , denoted by , is the angle spanned by a counter-clockwise rotation that brings a horizontal half-line starting at and directed towards increasing -coordinates to coincide with the half-line starting at and passing through . We consider slopes that are equivalent modulo as the same slope. Observe that . We only deal with planar monotone drawings of trees, as it was proved by Angelini et al. that every monotone drawing of tree is planar [1].

Let be a tree rooted at a vertex . Denote by the subtree of rooted at a vertex . By we denote the number of vertices of . Let be a child of . By we denote the tree that consists of edge and . In the rest of the paper, we assume that all tree edges are directed away from the root. A rooted tree is said to be ordered if there is an order imposed on the children of each vertex. A drawing is said to respect the ordering of the tree (or the embedding) if the children of a vertex are drawn around it in the specified order.

When producing a grid drawing, it is common to refer to the side-length of the required grid and to its dimensions. We emphasize that we measure length (width/height) in units of distance, but when we denote the dimensions of a grid we use the number of grid points in each dimension. So, a grid of width and height fits in a grid.

### 2.1 Slope-disjoint Tree Drawings

Angelini et al. [1] defined the notion of slope-disjoint tree drawings. Let be a drawing of a rooted tree . is called a slope-disjoint drawing of if the following properties are satisfied:

1. For every vertex , there exist two angles and , with such that for every edge that is either in or that enters from its parent, it holds that .

2. For every two vertices such that is a child of , it holds that .

3. For every two vertices having the same parent, it holds that either or .

The idea behind the definition of slope-disjoint tree drawings is that all edges in the subtree as well as the edge entering from its parent have slopes that strictly fall within the angle-range defined for vertex . is called the angle-range of with and being its boundaries. The convex angle formed between two half-lines with slopes and is denoted by and is called angle-range length of .

Angelini et al. [1] proved the following theorems:

###### Theorem 1 (Angelini et al.[1])

Every monotone drawing of a tree is planar.

###### Theorem 2 (Angelini et al.[1])

Every slope-disjoint drawing of a tree is monotone.

In order to simplify the description of our algorithm, we extend the definition of slope-disjoint tree drawings to allow for angle-ranges of adjacent vertices (parent-child relationship) or sibling vertices (children of the same parent) to share angle-range boundaries.

###### Definition 1

A tree drawing of a rooted tree is called a non-strictly slope-disjoint drawing if the following properties are satisfied:

1. For every vertex , there exist two angles and , with such that for every edge that is either in or enters from its parent, it holds that .

2. For every two vertices such that is a child of , it holds that .

3. For every two vertices with the same parent, it holds that either or .

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 “” 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 is also a slope-disjoint drawing.

###### Proof

Intuitively, the theorem holds since we can always adjust (by a tiny amount) the angle-ranges of vertices that share an angle-range boundary so that, after the adjustment no two tree vertices share an angle-range boundary. Note that the actual drawing of the tree does not change. Only the angle-ranges are adjusted.

More formally, let be a non-strictly slope-disjoint drawing of a tree rooted at . We show how to compute for every vertex a new angle-range such that the current drawing of with the new angle-range is slope-disjoint.

Let be the edge that connects the parent of to in , for .

We make use of the following definitions:

 δ1 =minu∈T∖r(slope(e(u))−a1(u)) δ2 =minu∈T∖r(a2(u)−slope(e(u))) δ =min(δ1,δ2)

For any vertex it holds that:

 slope(e)−a1(u)≥δ (1) a2(u)−slope(e)≥δ (2)

By Property-1 of the non-strictly slope-disjoint drawing, we have that and, therefore, . By adding the two previous inequalities we get that,

 \lx@crefcreftype refnumeq:d1+\lx@crefcreftype refnumeq:d2⇒a2(u)−a1(u)≥2δ\leavevmode\nobreak\ where\leavevmode% \nobreak\ u∈T∖r (3)

For any descendant of the root of , by inductive use of Property-2 of the non-strictly slope-disjoint drawings, it holds that:

 a1(r) ≤a1(v) (4) a2(r) ≥a2(v) (5)

By subtracting Eq. 5 from Eq. 4 we get

 \lx@crefcreftype refnumeq:a2−\lx@crefcreftype refnumeq:a1⇒a2(r)−a1(r)≥a2(v)−a1(v)\lx@crefcreftype refnumeq:i1≥2δ

Therefore, for any vertex it holds:

 a2(u)−a1(u)≥2δ (6)

Let the root of be at level-0, let be a vertex in level- and let be the height of tree . Define the slope-disjoint angle-ranges for each vertex as follows:

 b1(u)={a1(r)if u=ra1(u)+δ⋅ih+1if u≠r
 b2(u)={a2(r)if u=ra2(u)−δ⋅ih+1if u≠r

Firstly, we show that the new angle-range boundaries satisfy Property-2 of slope-disjoint drawings. Let be a level- vertex and be its child. By the non-strictly slope-disjoint Property-2, it holds that:

 a1(u)≤a1(v) ⇒a1(u)+δ⋅ih+1

Similarly, we have that . We also have,

 b2(v)−b1(v) =a2(v)−δ⋅i+1h+1−(a1(v)+δ⋅i+1h+1) =(a2(v)−a1(v))−2δ⋅i+1h+1 \lx@crefcreftype refnumeq:2d≥2δ−2δ⋅i+1h+1 =2δ⋅(1−i+1h+1) =2δ⋅h−ih+1 >0 ⇒b1(v)

The last inequality holds since vertex has a child and, thus, is at a level such that . Thus, Property-2 holds.

Secondly, we show that the new angle-range boundaries satisfy Property-3 of slope-disjoint drawings. Let and be two level- vertices having the same parent. Then, by Property-3 of the non-strictly slope disjoint drawings we have that or . The two cases are symmetric, so we only prove that when . As proved for the case of Property-2, and and thus, it remains to prove that . But we have that,

 a2(v1)≤a1(v2) ⇒a2(v1)−δ⋅ih+1

Finally, we turn our attention to Property-1 of slope-disjoint drawings. Angle-range boundaries and satisfy Property-1 of non-strictly slope-disjoint drawings and thus, for every vertex at level and for every edge that belongs in or that enters from its parent inequality Eq. 1 holds. By definition, we have that which implies

 a1(u)=b1(u)−δ⋅ih+1 (7)
 Eq. 1 \lx@crefcreftype refnumeq:2⇔slope(e)−(b1(u)−δ⋅ih+1)≥δ ⇔slope(e)−b1(u)≥δ⋅(1−ih+1) ⇔slope(e)−b1(u)≥δ⋅(h+1−ih+1) ⇒slope(e)−b1(u)>0

The last inequality holds since and . The later is true since is a level- vertex where .

In a similar way, we show that and we conclude that . Thus, Property-1 of slope-disjoint drawing is also satisfied.

###### Theorem 3

Every non-strictly slope-disjoint drawing of a tree is monotone and planar.

###### Proof

By Lemma 1 every non-strictly slope-disjoint drawing of a tree is slope-disjoint and by Theorem 1 and Theorem 2 it is monotone and planar.

### 2.2 Locating Points on the Grid

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

Consider two angles , with and let . Then, edge connecting the origin to point satisfies .

###### Proof

Let and be the half-lines from origin with slopes and , respectively. Let and be the intersection points of and with line , respectively. We prove that , so a point of the grid must lie between and , since the -coordinate is integer and line segment is parallel to -axis as seen in Figure 2.

From trigonometry, we know identities :

 tan(a−b)=tan(a)−tan(b)1+tan(a)⋅tan(b) (8)

and

 tan(a)>a , when 0

By Eq. 8, it holds that and thus, for it holds:

 tan(a)−tan(b)>tan(a−b), when 0≤a,b≤π2 (10)

The coordinates of point are while the coordinates of point are . Therefore,

 |ab| =tan(θ2)⋅d−tan(θ1)⋅d =(tan(θ2)−tan(θ1))⋅d \lx@crefcreftype refnumeq:i2>tan(θ2−θ1)⋅d \lx@crefcreftype refnumeq:t2≥(θ2−θ1)⋅d =(θ2−θ1)⋅⌈1θ2−θ1⌉ ≥(θ2−θ1)⋅1θ2−θ1 =1

Given that , the grid point falls within the angular sector defined by half-lines and and satisfies the lemma.

###### Lemma 3

Consider angles , with and let . Then, a grid point such that the edge that connects the origin to satisfies , can be identified as follows:

 θ2−θ1>π4 \rm\leavevmode\nobreak\ :\leavevmode\nobreak\ p=(1,1) π4≥θ2−θ1>arctan(12) arctan(12)≥θ2−θ1

Moreover, if is the identified point, it also holds that:

 max(x,y)≤π2⋅1θ2−θ1

###### Proof

See Figure 2 for points, slopes and angular sectors relevant to Lemma 3. For each case, we show that the identified points in the statement of the lemma satisfy the “slope” (“”) and the “length” (“”) conditions.

Case-1: .

Point is the identified point. In this case, the edge from the origin to has slope . For the “slope” condition, given that and , it is enough to show that which implies that . If we have that,

 θ2−θ1>π4⇔θ2 >θ1+π4 >π4+π4 =π2

A clear contradiction. So, . In a similar way we can show that .

For the “length” condition, we have to show that,

 max(1,1)=1≤π2⋅1θ2−θ1

This is true since,

 0≤θ1<θ2≤π2 ⇒θ2−θ1≤π2 ⇔1θ2−θ1≥1π2 ⇔π21θ2−θ1≥π2⋅1π2=1
Case-2: .

We first establish the “slope” condition.

For the case where the identified point is . We note that the slope of the edge from the origin to is . Then, by the assumption we have:

 θ2−θ1>arctan(12)⇔θ2 >θ1+arctan(12) ≥arctan(12)

It follows that .

For the case where the identified point is . We note that the slope of the edge from the origin to is . By the assumption, and by taking into account that , we have:

 θ2−θ1>arctan(12)⇔θ2 >θ1+arctan(12) ≥arctan(12)+arctan(12) =2⋅arctan(12) >2⋅π8 =π4

It follows that .

For the case where the identified point is . We note that the slope of the edge from the origin to is . We want to establish that . This can be easily proved by taking into account that as well as that .

For the “length” condition, it is enough to show that:

 max(max(2,1),max(1,1),max(1,2))=2≤π2⋅1θ2−θ1

This is true since,

 θ2−θ1 ≤π4 ⇔1θ2−θ1 ≥1π4 ⇔π21θ2−θ1 ≥π2⋅1π4 =2
Case-3: .

We first establish the “slope” condition. In the case where , by Lemma 2 the identified point immediately satisfies the “slope” condition. The same holds for the symmetric case where . Finally, in the case where the slope condition trivially holds since the edge from the origin to has slope .

For the “length” condition, we note that in all three cases we have that,

 max(x,y)≤d =⌈1θ2−θ1⌉ <1θ2−θ1+1

But it also holds:

 1x+1≤π2⋅1x , where 0

And since we get that,

 max(x,y)<1θ2−θ1+1\lx@crefcreftype refnumeq:aab≤π2⋅1θ2−θ1

The lemma is now proved.

In this Section, we describe an algorithm that builds a monotone drawing of an -vertex tree on a grid of size at most . We refer to this algorithm as “traditional” since it satisfies all drawing conventions followed by all algorithms that have appeared in the literature, that is, it take as input a rooted ordered tree and produces a monotone drawing of where (i) the root of is drawn at the origin of the drawing, (ii) the drawing of is confined in the first quadrant, and (iii) the order of the children of each node of is respected. The algorithm produces a non-strictly slope-disjoint tree drawing which, by Theorem 3, is monotone and planar.

***

In order to describe a non-strictly slope-disjoint tree drawing, we need to identify for each vertex of the tree a grid point to draw as well as to assign to it two angles , , with . For every tree node, the identified grid point and the two angles should be such that the three properties of the non-strictly slope-disjoint drawings are satisfied.

The basic idea behind our algorithm is to split in a balanced way the angle-range of vertex to its children based on the size of the subtrees rooted at them. The following strategy formalizes this idea.

###### Strategy

Let be a non-leaf vertex of an -vertex rooted tree such that we already have assigned values for and , with . Let , be the children of . We assign angle-range for the children of in the following way:

 a1(vi) a2(vi) \rm\leavevmode\nobreak\ =\leavevmode\nobreak\ a1(vi)+(a2(u)−a1(u))⋅|Tvi||Tu|−1,  1≤i≤m

The following lemma proves that Strategy 3 satisfies Property-2 and Property-3 of the non-strictly slope-disjoint drawings.

###### Lemma 4

Let be a vertex of the rooted tree such that we already have assigned values for and , with . Let , be the children of in . If we assign values for angle-ranges of the children of according to Strategy 3, then Property-2 and Property-3 of the non-strictly slope-disjoint drawings are satisfied.

###### Proof

For Property-3, we have to show that for every , , it holds: . For any , we have that,

 a2(vj) =a1(vj)+(a2(u)−a1(u))⋅|Tvj||Tu|−1 >a1(vj)

The last inequality holds since, by assumption, and because the size of a rooted tree is always positive. Therefore,

 a1(v1)

So, for any , , it holds that and, thus, Property-3 holds.

For Property-2, since we proved that , it is sufficient to show that and . The first part trivially holds since by definition. For the second part, by using repeatedly the assignment for and provided in the statement of the lemma we get that,

 a2(vm)=a1(v1)+(a2(u)−a1(u))∑mi=1|Tvi||Tu|−1

Since the subtree rooted at , consists of the root vertex and the subtrees rooted at ’s children, it holds that . It follows that and Property-2 is satisfied.

###### Observation

If a vertex has only one child, say , then the angle assignment Strategy 3 assigns and , 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 Strategy 3, Procedure DrawVertices which assigns each tree vertex to a grid point according to Lemma 3 and Procedure BalancedTreeMonotoneDraw which assigns the root to point with angle-range and initiates the drawing of the tree.

###### Lemma 5

The drawing produced by Algorithm 1 is monotone and planar.

###### Proof

The angle-range assignment of Strategy 3 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 3, it is monotone and planar.

It remains to establish a bound on the grid size required by Algorithm 1. Our proof uses induction on the number of tree vertices having more than one child.

###### Lemma 6

Let be a rooted tree and be a vertex. Consider as assigned by Algorithm 1. Then the side-length of the grid which Algorithm 1 uses for the drawing of the subtree rooted at is bounded by:

 (|Tu|−1)π21ϕu

###### Proof

We use induction on the number of vertices having at least two children. Let be the number of vertices of with at least two children.

Base Case (i=0):

In that case, is just a path and by Observation 3, Algorithm 1 assigns to every vertex the same angle-range. From this observation, for any vertex , it holds that , therefore by Lemma 3 we have that each edge expands our grid at most by:

 π21ϕu

Since the tree has vertices, we expand the grid times, therefore the side-length of the grid required for the drawing of tree is:

 (|Tu|−1)π21ϕu

The base case is now settled.

Induction Step:

We assume that for any rooted subtree which contains at most vertices with at least two children each, the statement holds. We prove that for any subtree rooted at vertex with vertices in having at least two children each, the statement also holds.

At first we prove that the only case of interest is when the subtree is rooted at a vertex with at least two children. Let’s assume is the union of a path starting from and ending at where each vertex has exactly one child except and the subtree rooted at . The number of vertices in having at least two children is by assumption since the vertices in the path between and have exactly one child. If the statement holds for we have, by Observation 3, and , and thus,

 ϕv=a2(v)−a1(v)=a2(u)−a1(u)=ϕu (12)

The side-length of the required grid for is,

 (|Tv|−1)π21ϕv(???)