1 Introduction

The \(w\times h\) -grid (or grid of width w and height h) consists of all grid-points (ij) that have integer coordinates \(1\le i\le w\) and \(1\le j\le h\), and all grid-edges that connect grid-points of distance 1. An EPG-representation of a graph G consists of an assignment of a vertex-path, \(path(v)\), to every vertex v in G such that \(path(v)\) is a path in a grid, and (vw) is an edge of G if and only if \(path(v)\) and \(path(w)\) have a grid-edge in common.

Since their initial introduction by Golumbic et al. [11], a number of papers concerning EPG-representations of graphs have been published. It is easy to see that every graph has an EPG-representation [11]. Later papers asked what graph classes can be represented if the number of bends in the vertex-paths is restricted (see e.g. [3, 4, 9, 13]) or gave approximation algorithms for graphs with an EPG-representation with few bends (see e.g. [8, 17]).

The main objective of this paper is to find EPG-representations such that the size of the underlying grid is small (rather than the number of bends in vertex-paths). As done by Golumbic et al. [11], we wonder whether additionally we can achieve monotonicity of vertex-paths. We say that \(path(v)\) is x -monotone if any vertical line that intersects \(path(v)\) intersects it in a single interval. It is xy -monotone if it is x-monotone and additionally any horizontal line that intersects \(path(v)\) intersects it in a single interval. Finally, it is \(xy^+\) -monotone if it is monotonically increasing, i.e., it is xy-monotone and the left endpoint is not above the right endpoint. An x -monotone EPG-representation is an EPG-representation where every vertex-path is x-monotone, and similarly an \(xy^+\) -monotone EPG-representation is an EPG-representation where every vertex-path is \(xy^+\)-monotone.

It is easy to see that every n-vertex graph has an EPG-representation in an \(O(n)\times O(n)\)-grid, i.e., with quadratic area. This is best possible for some graphs. In Sect. 4, we study lower bounds and show that there are m-edge graphs that require a grid of area \(\varOmega (m)\) in any EPG-representation and that there are pathwidth-k graphs that require height \(\varOmega (k)\) and area \(\varOmega (kn)\) in any EPG-representation.

Biedl and Stern [4] showed that pathwidth-k graphs have an EPG-representation of height k and width O(n), thus area O(kn). In Sect. 5, we prove a strengthening of that result. In particular, we show that every pathwidth-k graph has an \(xy^+\)-monotone EPG-representation of height O(k) and width O(n) thus matching the lower bound in this strongest of the models. This result implies, for example, O(n), \(O(n \log n)\) and \(O(n^{3/2})\) area bounds for \(xy^+\)-monotone EPG-representations of bounded pathwidth graphs, bounded treewidth graphs and all classes of graphs that exclude a minor, respectively. In fact, the result implies that all hereditary graph classes with o(n)-size balanced separators have \(o(n^2)\) area \(xy^+\)-monotone EPG-representations.

If the monotonicity requirement is dropped, better area bounds are possible for some graph classes. For example, in Sect. 6, we prove that graphs of bounded treewidth have O(n) area EPG-representations and that graphs of bounded genus (thus planar graphs too) have \(O(n \log ^2 n)\) EPG-representations.

2 Preliminaries

Throughout this paper, \(G=(V,E)\) denotes a graph with n vertices and m edges. We refer, e.g., to [6] for all standard notations for graphs. The pathwidth pw(G) of a graph G is a well-known graph parameter. Among the many equivalent definitions, we use here the following: pw(G) is the smallest k such that there exists a super-graph H of G that is a \((k{+}1)\)-colourable interval graph. Here, an interval graph is a graph that has an interval representation, i.e., an assignment of a (1-dimensional) interval to each vertex v such that there exists an edge if and only if the two intervals share a point. We may without loss of generality assume that the intervals begin and end at distinct x-coordinates in \(\{1,\dots ,2n\}\), and will do so for all interval representations used in this paper. We use \(I(v)=[\ell (v),r(v)]\) for the interval representing vertex v. It is well-known that an interval graph is k-colourable if and only if its maximum clique size is k.

Contracting an edge (vw) of a graph G means deleting both v and w, inserting a new vertex x, and making x adjacent to all vertices in \(G-\{v,w\}\) that were adjacent to v or w. A graph H is called a minor of a graph G if H can be obtained from G by deleting some vertices and edges of G and then contracting some edges of G. It is known that \(pw(H)\le pw(G)\) for any minor H of G.

3 From Proper VPG to EPG

A VPG-representation of a graph G consists of an assignment of vertex-paths in the grid to vertices of G such that (vw) is an edge of G if and only if \(path(v)\) and \(path(w)\) have a grid-point in common. Many previous EPG-representation constructions (see e.g. [11]) were obtained by starting with a VPG-representation and transforming it into an EPG-representation by adding a “bump” whenever two paths cross. The lemmas below formalize this idea, and also study how this transformation affects the grid-size and whether monotonicity is preserved.

We give the transformations only for proper VPG-representations, which satisfy the following: (a) Any grid-edge is used by at most one vertex-path. (b) If a grid-point p belongs to \(path(v)\) and \(path(w)\), then one of the vertex-paths includes the rightward edge at p and the other includes the upward edge at p Footnote 1.

Lemma 1

Let G be a graph that has a proper VPG-representation \(R_V\) in a \(w\times h\)-grid. Then any subgraph \(G'\) of G has an EPG-representation \(R_E\) in a \(2w\times 2h\)-grid. Furthermore, if \(R_V\) is x-monotone then \(R_E\) is x-monotone.

Proof

Double the resolution of the grid by inserting a new grid-line after each existing one. For each edge (vw) of \(G'\), consider the two paths \(path(v)\) and \(path(w)\) that represent v and w in \(R_V\). Since (vw) was an edge of G, the vertex-paths share a grid-point (ij) in \(R_V\), which corresponds to point (2i, 2j) in \(R_E\).

Since \(R_V\) is proper, we may assume (after possible renaming) that \(path(v)\) uses the rightward edge at (2i, 2j), and \(path(w)\) uses the upward edge at (2i, 2j). Re-route \(path(v)\) by adding a “bump”

in the first quadrant of (2i, 2j). See also Fig. 1(a) and (b). Note that \(path(w)\) is unchanged in the vicinity of (2i, 2j), and the bump added to \(path(v)\) is x-monotone. So if \(R_V\) is x-monotone then so are the resulting vertex-paths.

Since \(R_V\) is proper, no other vertex-path used (ij) in \(R_V\), and therefore no other vertex-path in \(R_E\) can use any grid-edge of this bump. Therefore no new adjacencies are created, and \(R_E\) is indeed an EPG-representation of \(G'\).     \(\square \)

Fig. 1.
figure 1

Transforming a proper VPG-representation. We only show the transformation for the edge from blue (dotted) to green (dashed) vertex. (Color figure online)

We now give a second construction, which is similar in spirit, but re-routes differently in order to preserve \(xy^+\)-monotonicity.

Lemma 2

Let G be a graph that has a proper VPG-representation \(R_V\) in a \(w\times h\)-grid with \(xy^+\)-monotone vertex-paths. Then any subgraph \(G'\) of G has an \(xy^+\)-monotone EPG-representation \(R_E\) in a \((2w+h)\times 2h\)-grid

Proof

We do two transformations; the first results in a proper VPG-representation \(R_V'\) that has some special properties such that it can then be transformed into an EPG-representation.

The first transformation is essentially a skew. Map each grid-point (ij) of \(R_V\) into the corresponding point \((2i+j,2j)\). Any horizontal grid-edge used by a vertex-path is mapped to the corresponding horizontal grid-edge, i.e., we map a horizontal grid-edge \((i,j)-(i{+}1,j)\) of \(R_V\) into the length-2 horizontal segment \((2i+j,2j)-(2(i+1)+j,2j)\) that connects the corresponding points. Every vertical grid-edge \((i,j)-(i,j{+}1)\) is mapped into the zig-zag path

that connects the corresponding points. See also Fig. 1(a) and (c). It is easy to verify that this is again a proper VPG-representation of exactly the same graph, and vertex-paths are again \(xy^+\)-monotone.

Now view \(R_V'\) as an EPG-representation. Since \(R_V'\) is proper, currently no edge is represented. We now modify \(R_V'\) such that intersections are created if and only if an edge exists. Consider some edge (vw) of \(G'\). Since it is an edge of G, there must exist a point (ij) in \(R_V\) where \(path(v)\) and \(path(w)\) meet. Since \(R_V\) is proper, we may assume (after possible renaming) that \(path(v)\) uses the rightward edge at (ij) while \(path(w)\) uses the upward edge at (ij). Consider the corresponding point \((2i+j,2j)\) in \(R_V'\), and observe that \(path'(v)\) and \(path'(w)\) (the vertex-paths in \(R_V'\)) use its incident rightward and upward edges, respectively. Moreover, \(path'(w)\) uses the “zig-zag” \((2i+j,2j)-(2i+j,2j+1)-(2i+j+1,2j+1)\). We can now re-route the vertex-path of w to use instead \((2i+j,2j)-(2i+j+1,2j)-(2i+j+1,2j+1)\), i.e., to share the horizontal edge with \(path'(w)\) and then go vertically. See Fig. 1(d). Thus the two paths now share a grid-edge. Since no other vertex-paths used (ij) in \(R_V\), this re-routing does not affect any other intersections and overlaps. So we obtain an EPG-representation of G, and one easily verifies that it is \(xy^+\)-monotone.     \(\square \)

Theorem 1

Every graph G with n vertices has an \(xy^+\)-monotone EPG-representation in a \(3n\times 2n\)-grid.

Proof

It is very easy to create a proper VPG-representation of the complete graph \(K_n\) in an \(n\times n\)-grid, using a \(\varGamma \)-shape (hence an \(xy^+\)-monotone vertex-path). Namely, place the corner of the \(\varGamma \) of vertex i at \((i{-}1,i)\) and extending the two arms to \(y=1\) and \(x=n\). For vertex 1, the grid-edge \((0,1)-(1,1)\) is not needed and can be omitted to save a column. See Fig. 2. Since G is a subgraph of \(K_n\), the result then follows by Lemma 2.     \(\square \)

Fig. 2.
figure 2

A VPG-representation of \(K_n\), and an EPG-representation for any graph. In gray areas vertex-paths may get re-routed to create shared grid-edges.

Contrasting this with existing results, it was already known that any graph has an EPG-representation [11], but our construction additionally imposes \(xy^+\)-monotonicity, and our grid-size is \(O(n^2)\), rather than O(nm).

4 Lower Bounds

We now turn to lower bounds. These hold for arbitrary EPG-representations; we make no use of monotonicity.

Theorem 2

Let G be a triangle-free graph with m edges. Then any EPG-representation of G uses at least m grid-edges (hence a grid of area \(\varOmega (m)\)).

Proof

If G has no triangle, then the maximal clique-size is 2. Hence no grid-edge can belong to three or more vertex-paths. Consequently, for every edge (vw) we must have at least one grid-edge (the one that is common to \(path(v)\) and \(path(w)\)). No grid-edge belongs to three vertex-paths, and so there must be at least m grid-edges.     \(\square \)

A consequence of Theorem 2 is that \(K_{n,n}\) requires \(\varOmega (n^2)\) area in any EPG-representation. Later, we relate pathwidth to EPG-representations. For now, we note that \(K_{n-k,k}\) is an n-vertex triangle-free graph with pathwidth k and \(\varTheta (kn)\) edges. Together with Theorem 2, this implies:

Corollary 1

For every \(k\ge 1\) and every \(n\ge 2k\), there exists an n-vertex pathwidth-k graph G for which any EPG-representation of G uses \(\varOmega (kn)\) grid-edges (hence a grid of area \(\varOmega (kn)\)).

One wonders whether there are graphs that have only a linear number of edges and still require a big, even quadratic, area. The following lower bound, also based on pathwidth, allows us to answer this question in the affirmative.

Theorem 3

Let G be a graph that has an EPG-representation in a grid with h rows and for which any grid-edge is used by at most c vertex-paths. Then \(pw(G)\le c(3h-1)-1\).

Proof

For every vertex v, define I(v) to be the x-projection of \(path(v)\). This is an interval since \(path(v)\) is connected. Define H to be the interval graph of these intervals. If (vw) is an edge, then \(path(v)\) and \(path(w)\) share a grid-edge, and hence the intervals I(v) and I(w) share at least one point. So G is a subgraph of H. We claim that H has clique-size \(\omega (H)\le 6h-2\); this implies the result.

Fix an arbitrary maximal clique D in H. It is well-known (see e.g. [10]) that, in the projected interval-representation, there exists a vertex v such that D corresponds to those vertices whose intervals intersect the left endpoint \(\ell (v)\). Hence for any vertex w in D, at least one grid-edge of \(path(w)\) is incident to a grid-point with x-coordinate \(\ell (v)\). There are only \(3h-1\) such grid-edges (2h horizontal ones and \(h-1\) vertical ones), and each of them can belong to at most c vertex-paths. Hence \(|D|\le c(3h-1)\), which proves the claim.     \(\square \)

In particular, if G is triangle-free then no three vertex-paths can share a grid-edge. Applying the theorem with \(c=2\) for such graphs we get:

Corollary 2

Any triangle-free graph with pathwidth k requires an \(\varOmega (k)\times \varOmega (k)\)-grid and thus \(\varOmega (k^2)\) area in any EPG-representation.

So all that remains to do for a better lower bound is to find a graph that has few edges yet high pathwidth. For this, we use expander-graphs, which are graphs such that for any vertex-set S the ratio between the boundary of S (the number of vertices in S with neighbors in \(V-S\)) and |S| is bounded from below.

Theorem 4

There are n-vertex graphs with O(n) edges for which any EPG-representation requires \(\varOmega (n^2)\) area.

Proof

It is known that expander-graphs of maximum degree 3 exist (see e.g. [15]) Let G be one such graph. It hence has O(n) edges. Since G is an expander, it has pathwidth \(\varOmega (n)\) (see e.g. [12]). Subdivide all edges of G to obtain a bipartite graph \(G'\) that has O(n) vertices and edges. This operation cannot decrease the pathwidth since G is a minor of \(G'\). So \(pw(G')\in \varOmega (n)\). Since \(G'\) is triangle-free, any EPG-representation of \(G'\) must have height \(\varOmega (n)\), and a symmetric argument shows that it must have width \(\varOmega (n)\).     \(\square \)

5 Upper Bounds on \(xy^+\)-monotone EPG Representations

Corollaries 1 and 2 imply that the best upper-bounds for EPG-representations in terms of pathwidth have height \(\varOmega (k)\) and area \(\varOmega (kn)\). Naturally, one wonders whether this bound can be matched. As noted in the introduction, Biedl and Stern showed that any graph with pathwidth k has an EPG-representation of height k and area O(kn) [4]. We now use a completely different approach to strengthen their result and obtain \(xy^+\)-monotone EPG-representations of pathwidth k graphs with optimal height O(k) and optimal area O(kn).

Theorem 5

Every graph G of pathwidth k has an \(xy^+\)-monotone EPG-representation of height \(8k+O(1)\) and width O(n), thus with O(kn) area.

Proof

Recall that G is a subgraph of a \((k{+}1)\)-colourable interval graph H. By Lemma 2, it suffices to show the following:

Lemma 3

Let H be a \((k{+}1)\)-colourable interval graph with interval representation \(\{I(v)=[\ell (v),r(v)] : v\in V\}\). There exists a proper VPG-representation with \(xy^+\)-monotone vertex-paths of a supergraph of H such that

  1. 1.

    all vertex-paths are contained within the \([2,2n+1]\times [-2k-2,2k+1]\)-grid (more precisely, the x-range is \([2\min _{v\in V} \ell (v), 1+2 \max _{v\in V} r(v)]\));

  2. 2.

    \(path(v)\) contains a horizontal segment whose x-range is \([2\ell (v),2r(v)]\) and whose y-coordinate is negative; and

  3. 3.

    some vertical segment \(path(v)\) includes the segment \(\{2r(v)\} \times [-1,1]\).

We prove the lemma by induction on k. We may assume that H is connected, for if it is not, then obtain representations of each connected component separately and combine them. The x-ranges of intervals of each component are disjoint (else there would be an edge), and so the representations of the components do not overlap by (1).

The claim is straightforward for \(k=0\): Since H is connected and 1-colourable, it has only one vertex v. Set \(path(v)\) to use the two segments \([2\ell (v),2r(v)]\times \{-1\}\) and \(\{2r(v)\}\times [-1,1]\). All claims hold.

Now assume that \(k\ge 1\). We find a path P of “farthest-reaching” intervals as follows. Set \(a_1:=\text{ argmin }_{v\in V} \ell (v)\), i.e., \(a_1\) is the interval that starts leftmost. Assume \(a_i\) has been defined for some \(i\ge 1\). Let \(\mathcal{A}_i\) be the set of all vertices v with \(\ell (a_i)<\ell (v)<r(a_i)<r(v)\). If \(\mathcal{A}_i\) is empty then stop the process; we have reached the last vertex of P. Else, set \(a_{i+1}:=\text{ argmax }_{v\in \mathcal{A}_i} r(v)\) to be the vertex in \(\mathcal{A}_i\) whose interval goes farthest to the right, and repeat. See also Fig. 3. Let \(P=a_1,a_2,\dots ,a_p\) be the path that we obtained (this is indeed a path since \(I(a_i)\) intersects \(I(a_{i+1})\) by definition).

Fig. 3.
figure 3

An interval graph (bold intervals denote the path P chosen in Theorem 5), and its proper VPG-representation with x-monotone vertex-paths.

Claim

P is an induced path.

Proof

It suffices to show that \(r(a_i)<\ell (a_{i+2})\) for all \(1\le i\le p-2\). Assume for contradiction that \(\ell (a_{i+2}) < r(a_i)\) for some \(1\le i\le p-2\). We show that this contradicts the choice of P as the vertices that go farthest right. Namely, let \(j\le i\) be the smallest index such that \(\ell (a_{i+2}) < r(a_j)\). If \(j>1\) then \(\ell (a_{i+2})>r(a_{j-1})>\ell (a_j)\) by definition of j and \(\mathcal{A}_{j-1}\). If \(j=1\) then \(\ell (a_{i+2}) \ge \min _{v\in V} \ell (v) = \ell (a_1)=\ell (a_j)\), and the inequality is strict since \(i+2\ne 1\). Thus in both cases \(\ell (a_{i+2})>\ell (a_j)\). Therefore \(\ell (a_j)<\ell (a_{i+2})<r(a_j)\le r(a_{i+1})<r(a_{i+2})\), which implies \(a_{i+2}\in \mathcal{A}_j\). By \(r(a_{j+1})\le r(a_{i+1})<r(a_{i+2})\) this contradicts the choice of \(a_{j+1}\) as \(\text{ argmax }_{v\in \mathcal{A}_j} r(v)\).     \(\square \)

By definition \(a_1\) is the leftmost interval, i.e., \(\ell (a_1)=\min _{v\in V} \ell (v)\). We claim that \(a_p\) is the rightmost interval, i.e., \(r(a_p)=\max _{v\in V} r(v)\). Assume for contradiction that some vertex v has an interval that ends farther right. By connectivity we can choose v so that it intersects \(I(a_p)\), thus \(\ell (v)<r(a_p)<r(v)\). Let \(j\le p\) be maximal such that \(\ell (v)<r(a_j)\). Similarly, as in the claim, one argues that \(v\in \mathcal{A}_j\), and therefore v, rather than \(a_{j+1}\), should have been added to path P.

We are now ready for the construction. Define \(H':=H-P\). Since the intervals of P cover the entire range \([\min _{v\in V} \ell (v),\max _{v\in V} r(v)]\), any maximal clique of H contains a vertex of P. Therefore the maximum clique-size of \(H'\) satisfies \(\omega (H')\le \omega (H)-1\), which implies (for an interval-graph) that \(\chi (H')\le \chi (H)-1\), hence \(H'\) is k-colourable. Apply induction to \(H'\) (with the induced interval representation) and let \(\varGamma '\) be the resulting VPG-representation.

Since \(\varGamma '\) uses only orthogonal vertex-paths, we can insert two rows each above and below the x-axis by moving all other bends up/down appropriately. Now set \(path(a_i)\) to be

where \(Y=1\) if i is odd and \(Y=2\) if i is even. We omit the rightmost horizontal segment for \(i=p\) (because \(a_{p+1}\) is undefined). See also Fig. 4.

Fig. 4.
figure 4

Representation with xy-monotone vertex-paths.

Note that these vertex-paths satisfy conditions (2) and (3). Also note that for any \(1\le i<p\), the vertex-paths of \(a_i\) and \(a_{i+1}\) intersect, namely at \((2r(a_{i+1}),1)\) if i is odd and at \((2\ell (a_{i+1}),-2)\) and \((2r(a_i),-1)\) if i is even. It remains to show that for any edge \((w,a_i)\) (for some \(1 \le i \le p\) and \(w\not \in P\)) the vertex-paths intersect. Here we have three cases (Fig. 4 illustrates the \(\ell \)th case for edge \((w_\ell ,a_{\ell +1})\)):

  1. 1.

    If \(r(w)<r(a_i)\), then \(\ell (a_i)<r(w)\), else the intervals would not intersect. By (3), and since we inserted new rows around the x-axis, we know that \(path(w)\) contains the vertical segment \(2r(w) \times [-3,3]\). Therefore \(path(a_i)\) intersects this segment at \((2r(w),-Y)\) where \(Y\in \{1,2\}\).

  2. 2.

    If \(\ell (w)<\ell (a_i)\), then \(\ell (a_i)<r(w)\), else the intervals would not intersect. By (2), and since we inserted new rows around the x-axis, we know that \(path(w)\) has a horizontal segment \([2\ell (w),2r(w)]\times {-}Y\) for some \(Y\ge 3\). Therefore \(path(a_i)\) intersects this segment at \((2\ell (a_i),-Y)\).

  3. 3.

    Finally assume that \(\ell (a_i)<\ell (w)\) and \(r(a_i)<r(w)\). We must have \(\ell (w)<r(a_i)\), else the intervals would not intersect. Therefore \(w\in \mathcal{A}_i\). By choice of \(a_{i+1}\) we have \(r(w)\le \max _{v\in \mathcal{A}_i} r(v) = r(a_{i+1})\). By (3), and since we inserted new rows around the x-axis, we know that \(path(w)\) contains the vertical segment \(2r(w) \times [-3,3]\). By \(r(w)\le r(a_{i+1})\), therefore \(path(a_i)\) intersects this segment at (2r(w), Y) where \(Y\in \{1,2\}\).

Hence all edges of H are represented by intersection of vertex-paths and as one easily verifies, these are proper intersections. This finishes the induction and proves the theorem.     \(\square \)

We can use Theorem 5 to obtain small EPG-representations for other graph classes. Graphs of bounded treewidth have pathwidth at most \(O(\log n)\) [5]. Graphs excluding a fixed minor have treewidth \(O(\sqrt{n})\) [2]. A graph class has treewidth \(O(n^\epsilon )\) if it is hereditary (subgraphs also belong to the class) and has balanced separators (for any weight-function on the vertices there exists a small set S such that removing S leaves only components with at most half the weight) for which the size (the cardinality of S) is at most \(O(n^{\epsilon })\), for some fixed \(\epsilon \in (0,1)\) [7]. It is well known that hereditary graph classes with treewidth \(O(n^{\epsilon })\), for some fixed \(\epsilon \in (0,1)\), have pathwidth \(O(n^\epsilon )\) (see [5] for example), so graphs excluding a fixed minor have pathwidth \(O(\sqrt{n})\) and graphs with \(O(n^\epsilon )\)-size balanced separators have pathwidth \(O(n^\epsilon )\). This implies:

  • Graphs of bounded treewidth have \(xy^+\)-monotone EPG-representations in an \(O(\log n)\times O(n)\)-grid.

  • Graphs excluding a fixed minor have \(xy^+\)-monotone EPG-representations in an \(O(\sqrt{n})\times O(n)\)-grid.

  • Hereditary classes of graphs with \(O(n^\epsilon )\)-sized balanced separators for some \(\epsilon \in (0,1]\) have \(xy^+\)-monotone EPG-representations in an \(O(n^\epsilon )\times O(n)\)-grid.

The O(n) area result for bounded pathwidth graphs is tight by Theorem 2. Naturally, one wonders if the other three results in above are tight. The \(O(\sqrt{n})\times O(n)\)-grid bound applies, for example, to all planar graphs and more generally all bounded genus graphs. Some planar graphs with n vertices have pathwidth \(\varOmega (\sqrt{n})\) (the \(\sqrt{n}\times \sqrt{n}\)-grid is one example), so the height cannot be improved. But can the width or the area be improved? This turns out to be true for some graph classes if the monotonicity condition is dropped. In the next section, we show these improved bounds via a detour into orthogonal drawings. Some of these results are tight.

6 EPG-representations via Orthogonal Drawings

In this section, we study another method of obtaining EPG-representations, which gives (for some graph classes) even smaller EPG-representations. Define a 4-graph to be a graph where all vertices have degree at most 4. An orthogonal drawing of a 4-graph is an assignment of grid-points to vertices and grid-paths to edges such that the path of each edge connects the grid points of its end-vertices. Edges are allowed to intersect, but any such intersection point must be a true intersection, i.e., one edge uses only horizontal grid-edges while the other uses only vertical grid-edges at the intersection point.

Lemma 4

Let G be a 4-graph that has an orthogonal drawing in a \(w\times h\)-grid. Then any minor of G has an EPG-representation in a \(2w\times 2h\)-grid.

Proof

First delete from the orthogonal drawing all edges of G that are not needed for the minor H; this cannot increase the grid-size. So we may assume that H is obtained from G via edge contractions only.

We first explain how to obtain an EPG-representation of G. Double the grid by inserting a new row/column after each existing one. Every grid-point that belonged to a vertex v hence now corresponds to 4 grid-points that form a unit square; denote this by \(\square _v\). Duplicate all segments of grid-paths for edges in the adjacent new grid-line, and extend/shorten suitably so that the copies again form grid-paths, connecting the squares of their end. Thus for each edge (vw) we now have two grid-paths \(P_{v,w}^1\) and \(P_{v,w}^2\) from \(\square _v\) to \(\square _w\).

We now define \(path(v)\) (which will be a closed path) by tracing the edges of the orthogonal drawing suitably. To describe this in more detail, first arbitrarily direct the edges of G. Initially, \(path(v)\) is simply the boundary of \(\square _v\). Now consider each edge (vw) incident to v. If it is directed \(v\rightarrow w\), then remove from \(path(v)\) the grid-edge along \(\square _v\) that connects the two ends of \(P_{v,w}^1\) and \(P_{v,w}^2\), add these two grid-paths, and add the grid-edge \(e'\) along \(\square _w\) that connects these two paths. Note that \(e'\) also belongs to \(path(w)\), so with this \(path(v)\) and \(path(w)\) share a grid-edge and we obtain the desired EPG-representation of G. See Fig. 5.

It remains to argue that this can be turned into an EPG-representation of a graph H obtained from G via edge contractions. Suppose we want to contract edge (vw). The two grid-paths \(path(v)\) and \(path(w)\) share a grid-edge e that belongs to no other vertex-path. Delete e from both paths, and let the path of the contraction-vertex be the union of the two resulting open paths, which is again a closed path. Thus we obtain an EPG-representation of H where all vertex-paths are closed paths.

If desired, we can turn this into an EPG-representation with open paths by deleting for every \(v\in V\) one grid-edge from \(path(v)\) that is not shared with any other vertex-path. If \(\deg (v)\le 3\), then a suitable edge is the grid-edge of \(\square _v\) on the side where no edge attaches. If v has an outgoing edge \(v\rightarrow w\), then a suitable edge is any grid-edge of \(P_{v,w}^1\). We can achieve that one of these always holds as follows: If all vertex degrees of G are 4, then direct G by walking along an Eulerian cycle; then all vertices have outgoing edges. If some vertex v has degree 3 or less, then find a spanning tree T of G, root it at v, direct all tree-edges towards the root and all other arbitrarily. Either way, this direction satisfies that any vertex of degree 4 has at least one outgoing edge and we can delete an edge of each \(path(v)\) such that all vertex-paths are open paths.     \(\square \)

Fig. 5.
figure 5

Transforming an orthogonal drawing into an EPG-representation. For ease of reading we show the duplicated grid-line close to the original one.

We note that a somewhat similar transformation from orthogonal drawings was used recently to create pixel-representations [1], but in contrast to their result we do not need the orthogonal drawings to be planar. We use this lemma to obtain small EPG-representations for a number of graph classes (we will not give formal definitions of these graph classes; see [6]).

Corollary 3

All graphs of bounded treewidth (in particular, trees, outer-planar graphs and series-parallel graphs) have an EPG-representation in O(n) area. Graphs of bounded genus have an EPG-representation in \(O(n\log ^2n)\) area.

Proof

Let G be one such graph for which we wish to obtain the EPG-representation. G may not be a 4-graph, but we can turn it into a 4-graph by vertex-splitting, defined as follows. Let v be a vertex with 5 or more neighbours \(w_1,\dots ,w_d\). Create a new vertex \(v'\), which is adjacent to \(w_1,w_2,w_3\) and v, and delete the edge \((v,w_i)\) for \(i=1,2,3\). Observe that \(\deg (v')=4\) and \(\deg (v)\) is reduced by 2, so sufficient repetition ensures that all vertex degrees are at most 4. Let H be the resulting graph, and observe that G is a minor of H.

Every vertex v of G gives rise to at most \(\deg (v)/2\) new vertices in H, so H has at most \(n+m\) vertices. Since graphs of bounded treewidth have O(n) edges and graphs of bounded genus have O(n) edges, therefore H has O(n) vertices. Markov and Shi [16] argued that the splitting can be done in such a way that \(tw(H)\le tw(G)+1\). It is also not hard to see that with a suitable way of splitting, one can ensure that in the case of bounded genus graphs the graph H obtained by splitting has the same genus.

By Leiserson’s construction [14], 4-graphs of bounded treewidth have an orthogonal drawing in O(n) area and those of bounded genus have an orthogonal drawing in \(O(n\log ^2 n)\) area.     \(\square \)

For classes of 4-graphs, Lemma 4 and Leiserson’s construction [14] give directly the following stronger results:

Corollary 4

Hereditary classes of 4-graphs that have balanced separators of size \(O(n^\epsilon )\) with \(\epsilon <1/2\) have EPG-representation in O(n) area. Hereditary classes of 4-graphs that have balanced separators of size \(O(n^\epsilon )\) with \(\epsilon >1/2\) have EPG-representation in \(O(n^{2\epsilon })\) area.

The first bound in Corollary 4 is tight thanks to Theorem 2. The second bound is tight thanks to Corollary 2 and the fact that there are such classes of graphs which contain triangle-free graphs of pathwidth \(\varOmega (n^\epsilon )\), for example the class of finite 4-graphs that are subgraphs of the 3D integer grid with \(\epsilon =2/3\).