The problem of grid embedding of a graph is that of drawing onto a rectangular two-dimensional grid (called simply grid) such that each vertex corresponds to a grid point (an intersection of a horizontal and a vertical grid line) and the edges of correspond to paths of the grid. Grid embedding of graphs has been considered with different perspectives [1, 2, 3, 4, 5, 6]. In , the authors described an algorithm for embedding planar graphs and showed that the resulting embedding has edges with at most bends. The same authors later showed in  a simpler approach which provides an embedding in which each edge has at most bends. Embeddings having edges with at most bends were also considered in , where a linear-time algorithm is presented. In , linear-time algorithms were described for embedding planar graphs such that the resulting embedding is guaranteed to have edges with at most bends, with the exception of the octahedron, for which at most two edges with bends may be produced. In this same paper, the authors also provided an upper bound on the total number of bends of their embeddings. Note that, all of these results are related to the problem of finding embeddings of graphs in which the aim is to minimize the number of bends of the edges of the graph and/or the total number of bends.
In this paper, we introduce a similar problem: given a planar graph , find a grid embedding of in which the edges of correspond to pairwise non-intersecting paths of the grid, each one having no bends, such that the maximum number of bends, over all paths of , is minimized. So, this new problem shifts the focus on the number of bends of edges of to the number of bends of paths of . This problem has not yet been considered in the literature so far. For instance, the tree in Figure 1 is drawn in such a way that there is a path having bends (the path joining and ), and is the maximum number of bends in that drawing. However, this maximum number of bends can be decreased to (path joining and ), as Figure 1 illustrates.
This problem will find an application obtaining certain grid models of VPT EPT graphs We will define these classes of graphs next, and the application will be deferred to Section 3. Given a tree , called host tree, and a set of paths in , the vertex (resp. edge) intersection graph of paths in a tree (VPT (resp. EPT)) of is the graph denoted by VPT() (resp. EPT()) having as vertex set and two vertices are adjacent if the corresponding paths have in common at least one vertex (resp. edge). We say that is a VPT (resp. EPT) model of . Figure 2 shows a host tree and the family of paths in it, as well as the corresponding VPT() and EPT() graphs in Figures 2 and 2 respectively.
Instead of host trees, the graphs we are interested have a grid as the underlying structure from which a family of paths is taken. A graph is an edge intersection graph of paths of a grid if there is a collection of paths in a grid such that each vertex in corresponds to a member of and two vertices are adjacent if, and only if, the corresponding paths have in common at least one edge of the grid. We say that is an EPG model of . EPG graphs were first introduced by Golumbic, Lipshteyn and Stern in 2009 (c.f. ) motivated from circuit layout problems. The same authors showed that every graph is an EPG graph. Figure 2 illustrates the EPG graph corresponding to the family of paths presented in Figure 2.
A turn of a path at a grid point is called a bend and the grid point in which a bend occurs is called a bend point. An EPG model is a B-EPG model if each path has at most bends. A graph that admits a B-EPG model is called B-EPG. Therefore, the graph defined in Figure 2 is B-EPG, as the model shows. However, it is possible to show that there is a B-EPG model of and, thus, is also B-EPG. The problem of finding the least such that a given graph is B-EPG has been a question of great interest since EPG graphs were introduced. In particular, the B-EPG graphs have been widely studied. On the other hand, there are fewer results for graphs that are B-EPG, for . It was proved that the recognition problem for B-EPG is NP-complete and it was also proved that the recognition problem for B-EPG is also NP-complete. It is the standing conjecture that determining the least such that an arbitrary graph is B-EPG is NP-complete for general . References to all mentioned results can be found in .
In Section 2, we discuss the concept of straight model of trees. It is shown an algorithm that determines one such model in which the maximum number of bends over all paths of a tree is minimized. In Section 3, we employ our algorithm to obtain straight models of host trees that are used to build EPG models of VPT EPT graphs. An upper bound on the number of bends of EPG models of VPT EPT graphs is then derived. Concluding remarks are presented in Section 4.
2 Embedding trees in a grid
Let be a tree such that . Consider the problem of embedding such a tree in a grid , such that the vertices must be placed at grid points and the edges drawn as non-intersecting paths of with no bends, which we will call a straight model of , or simply an s-model of . Figure 1 depicts two possible s-models corresponding to a same tree. Given a path of , and an s-model of , the number of bends of is defined to be the number of bends of the grid path consisting of the concatenation of the (straight) paths of the grid corresponding to the edges in . In Figure 1, the path has bends, whereas the same path in Figure 1 has only bend.
Among all possible s-models, consider the problem of finding one in which the maximum number of bends of a path of , over all of them, is minimum. Note that, since every path of a tree is contained in a leaf-to-leaf path, among the paths that bend the most in a given s-model is a leaf-to-leaf path, and therefore those are the only ones to be considered. More formally, let be the set of all possible s-models of a given tree and be leaves of . The number of bends of the path connecting and in an s-model is denoted by . Therefore, and . Let
denote the number of bends of the path that bends the most in , and
the minimum number of bends of an s-model, over all of them. Figure 1 depicts an s-model of a tree such that , and therefore . Figure 1 shows another s-model of for which and, therefore, . It is possible to show that no s-model of has and, thus, .
We provide an algorithm that determines and finds an s-model for which . Before describing the algorithm, some more terminology will be required.
Given , let denote the maximum number of bends found in a single path having as extreme vertices and a leaf of , over all paths that contain . That is,
As examples, in Figure 1, , , . Note that , whereas .
Let and . Let be and . For , define “virtual” neighbors for which . Assume that the neighbors (both real and virtual) are ordered so that for all . As examples, (and ), (and ), (and ), and (and ). Let . Let be and . For , also define for which . Again, assume that the neighbors are ordered according to their respective values of . As examples, (and ), (and ), and (and ). Besides, (and ), and (and ). The s-model may be omitted from these notations when it is unambiguous.
A tree can be built from a single vertex by a sequence of vertex additions, each new vertex adjacent to exactly one vertex of for all . We will call that is incrementally built by . For instance, the tree of Figure 1 is incrementally built by .
Let and . We say that is balanced if and are mutually in the same horizontal or vertical grid line in (and, therefore, so are and ).
We are ready to present Algorithm 1, which consists of adding iteratively vertices to and, for each new vertex , traversing in post-order taking as the root. The operation to be carried out in each visited vertex is to balance if it is not balanced. To illustrate its execution, Figure 3 presents the output of the algorithm having the tree of Figure 1 as input. Each s-model corresponds to a partial s-model of the tree, as it is at the end of each iteration. Regarding the time complexity of the algorithm, it is possible to keep the values of stored for each and , and update them in constant time right after the balance step, based on which subtrees had their positions exchanged and on the respective values of from the neighbors . Since the algorithm performs post-order traversals in , the algorithm runs in time. The remaining of the section is devoted to the correctness of the algorithm, that is, to prove that if is the s-model produced by Algorithm 1 on input , then . We also provide some numerical results concerning the number of bends of trees.
An ordered pairis called critical in an s-model if
and is critical; or
and are critical.
In Figure 1, , , , and are examples of critical pairs, while , , and are not.
Let and be the connected component of that contains . Intuitively, is what remains of when all neighbors of , except , are removed along with the vertices that become disconnected from .
Let be a tree and . If is a critical pair in , then .
Let and , for all . The proof is by induction on . If , then . Assume and that the result holds for any such a tree with less than vertices. As is critical, then
if and is critical, then by induction hypothesis we have that . On the other hand, . Thus, .
if and are critical, then by induction hypothesis, and . Since and or will bend with respect to the edge , thus . On the other hand, . Thus, .
Let be a tree and . If is a critical pair in , then .
By Lemma 1, we have that . ∎
Let be the s-model after the application of the balance step of Algorithm 1 on s-model in a vertex which is not balanced. Then, .
Let denote the maximum number of bends found in leaf-to-leaf paths in that contain . Let and for all . Since is not balanced in , then and are not aligned in . Therefore, . On the other hand, . After the balance, only the paths that contain have their number of bends changed. Thus, . ∎
Let be the s-model after the call of Balance(, , ) of Algorithm 1, for some and . If , then is critical in .
Let be the s-model being transformed by the call of the procedure and its recursive calls, until its final state when the first procedure call returns. The proof is by induction on . If , then is trivially critical. Assume and that the result holds for any such a tree with less than vertices. The first part of the procedure is to call it recursively for each , where . Note that, since is equal to initially and , we have that , and therefore for all . Thus, . Since has less vertices than , we have by induction hypothesis that is critical in after the call of Balance(, , ). Let and , for all right before the balance step. Since , while for all , then . Thus, is aligned with and thus . As both and are critical, then is critical. ∎
Given a tree , let be the s-model produced by the execution of Algorithm 1 on input . Then, .
The proof is by induction on the number of vertices of . If , then consists of just a vertex , and . Suppose, the theorem holds for any input tree having less than vertices. Let be the tree before the addition of the last vertex and be the s-model of produced so far. By hypothesis induction, . If , then and, thus, . If , then the number of bends cannot have increased by more than unit, since the addition of could have increased the maximum number of bends, but by Lemma 2, the balance step cannot increase it. Thus, and all paths that bend the most (say, bends) have an extreme vertex on . Given a path with bends, walk through the vertices of from to the other extreme vertex of and let be the vertices such that and the others are those in which bends, ordered according to such a walk. Let be the vertex that immediately succeeds in this walk over (note that must be an internal vertex of , and thus is well defined for all ). We claim that, for all ,
and since and is critical by such a claim, we have by Corollary 1 that . Since , then , concluding the proof.
It remains to prove the claim, which is done by induction on . For , we have that and is clearly critical; besides, , validating the claim. So, assume and the claim holds for all values less than .
Since is a bend of , . Moreover, or, otherwise, the balance step of the algorithm on the parameter would have eliminated such a bend. Therefore, . Again, since is a bend, and there are no bends in between and , we have that . By induction hypothesis, and, thus, . On the other hand, as has exactly bends from to , there is no other way to continue the subpath of from to up to a leaf in using more than bends in order to not contradict the maximality of in number of bends. As a consequence, , proving property (ii) of the claim.
Let be the vertex that immediately precedes in . Let . Due to the maximality in the number of bends of , for all , we have that and, thus, . Therefore, after the calling of Balance(, , ), we have that is critical by Lemma 3. On the other hand, by induction hypothesis, and is critical. Let be the directed path from to . Since has no bends, and since , then for all . As is critical, so is for all (in particular, ). As both and are critical, then is critical, proving property (i) of the claim. ∎
Therefore, the correctness of the algorithm holds. Now, we turn our attention to some other properties regarding the number of bends of trees.
Consider a graph , and . We denote by and by . Let such that , and a balanced s-model of . Let and be the neighbors of in . We define as the tree with a single vertex and, for all , is the tree rooted in such that and the number of vertices of is the least possible. That is,
A rooted binary tree is an ordered tree with root in which every vertex has at most two children. The height of is the number of edges in the longest existing path that has as extreme vertices and a leaf of . An interior vertex of is a vertex that is not a leaf of . Consider . The distance from to is the length of the path connecting and in . The level of a vertex is the distance from to . A full binary tree is a binary tree in which every interior vertex has exactly two children and all leaves are at the same (highest) level. We denote by the full binary tree with height .
Consider a path in a tree and let be a subtree of . We say that follows through if, and only if, either or .
For all , .
By induction on . If , then is a tree with a single vertex and, thus, . If , then and, thus, and are leaves of . Therefore, . Assume that , for all . Consider the neighbors of , and , in . Since has the least number of vertices, we will show that . If , then is a leaf of and, thus, . Therefore, (contradiction!). If , there exists , such that . And then, there exists , which contradicts the minimality of . If , let , for all . Note that the path with bends, having as extreme vertices and leaves of and containing , must follow through , for some . Without loss of generality, assume that and are aligned. If follows through , there exists , which contradicts the minimality of . Else, if follows through , there exists , which contradicts the minimality of and if follows through , there exists , which, again, contradicts the minimality of . Thus, . Let , such that is aligned with . Note that the path having as extreme vertices and leaves of , which contains and has bends, must follow through . Otherwise, there would exist , such that , which contradicts the minimality of . Thus, . Notice that . By the minimality of , it follows that . Consider . Note that, in , and . By the minimality of , . By induction hypothesis, . Similarly, let . Then . Thus, . Therefore, . ∎
For all , .
By Lemma 4, . Thus, . ∎
Consider the problem of finding a tree with bends such that is minimum. Let be a tree with bends defined in the following way:
For , is a tree with a single vertex.
For , consider the path with bends. Therefore, each vertex is a bend of , for all . We define built from in the following way: for each , add to a disjoint copy of the tree , where , and add the edge , where is the root of .
See in Figure 4 two examples of ’s. We will show that is minimum. Note that , thus , for . Note also that, , for all and such that . Therefore, consider the following cases,
if is even,