Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

1 Introduction

In Tutte’s landmark paper “How to draw a graph”, he introduces barycentric coordinates as a tool to draw triconnected planar graphs. Given the positions of the vertices on the outer face (which must be in convex position), the positions of the remaining vertices are determined as the solutions of a set of equations. While the solutions can be approximated numerically, and symmetries tend to be reflected nicely in the resulting drawings, the ratio between the lengths of the longest edge and the shortest edge is exponential in many cases. This deficiency triggered research directed towards drawing graphs on grids of small size in both 2D and 3D for different graph drawing paradigms; Brandenburg et al. [12] listed this as an important open problem. In straight-line grid drawings, the vertices are at integer grid points and the edges are drawn as straight-line segments. Both Schnyder [36] and de Fraysseix et al. [30], gave algorithms for drawing any n-vertex planar graph on a grid of size \(O(n) \times O(n)\). There has also been research towards drawing subclasses of planar graphs on small-area grids. For example, any n-vertex outerplanar graph can be drawn in area \(O(n^{1.48})\) [19]. Similar research has also been done for other graph drawing problems, such as polyline drawings, where edges can have bends [9], orthogonal drawings, where edges are polylines consisting of only axis-aligned segments [9, 17], and for drawing graphs in 3D [21, 34, 35].

A bar visibility representation [37] draws a graph in a different way: the vertices are horizontal segments and the edges are realized by vertical line-of-sights between corresponding segments. Improving earlier results, Fan et al. [24] showed that any planar graph admits a visibility representation of size \((\lfloor 4n/3\rfloor -2)\times (n-1)\). Generalized visibility representations for non-planar graphs have been considered in 2D [13, 23], and in 3D [11]. In all these and many subsequent papers, the size of a drawing is measured as the area or volume of the bounding box.

Yet another approach to drawing graphs are the so-called contact representations, where vertices are interior-disjoint geometric objects such as lines, curves, circles, polygons, polyhedra, etc. and edges correspond to pairs of objects touching in some specified way. An early work by Koebe [32] represents planar graphs with touching disks in 2D. Any planar graph can also be represented by contacts of triangles [29], by side-to-side contacts of hexagons [22] and of axis-aligned T-shape polygons [2, 29]. 2D-contact representations of graphs with line segments [28], L-shapes [18], homothetic triangles [4], squares and rectangles [15, 25] have also been studied. Of particular interest are the so-called VCPG-representations introduced by Aerts and Felsner [1]. In such a representation, vertices are represented by interior-disjoint paths in the plane square grid and an edge is a contact between an endpoint of one path and an interior point of another. Aerts and Felsner showed that for certain subclasses of planar graphs, the maximum number of bends per path can be bounded by a small constant.

Contact representations in 3D allow us to visualize non-planar graphs, but little is known about contact representations in 3D: Any planar graph can be represented by contacts of cubes [26], and by face-to-face contact of boxes [14, 38]. Contact representations of complete graphs and complete bipartite graphs in 3D have been studied using spheres [6, 31], cylinders [5], and tetrahedra [39]. In 3D as well as in 2D, the complexity of a contact representation is usually measured in terms of the polygonal complexity (i.e., the number of corners) of the objects used in the representation.

In this paper, in contrast, we are interested in “building” graphs, and so we aim at minimizing the cost of the building material—think of unit-size Lego-like blocks that can be connected to each other face-to-face. We represent eachvertex by a connected set of building blocks, which we call a blob. If two vertices are adjacent, the blob of one vertex contains a block that is connected (face-to-face) to a block in the blob of the other. The blobs of two non-adjacent vertices are not connected. We call the building blocks pixels in 2D and voxels in 3D. Accordingly, the 2D and 3D variants of such representations are called pixel and voxel representations, respectively. We define the size of a pixel or voxel representation to be the total number of boxes it consists of. (We use box to denote either pixel or voxel when the dimension is not important.)

The same representation was introduced very recently and independently by Cano et al. [16] under the name mosaic drawings for interior-triangulated planar graphs and triangular, square, or hexagonal pixels. They want each blob to use a given number of pixels (to represent statistical data, such as population) and to imitate the shapes of given geometric objects (such as countries).

Although pixel representations can be seen as generalizations of VCPG-representations where grid subgraphs instead of grid paths are used, minimizing or bounding the size of such representations has so far been studied neither in 2D nor in 3D.

Our Contribution. We first investigate the complexity of our problem: finding minimum-size representations turns out to be NP-complete (Sect. 2). Then, we give lower and upper bounds for the sizes of 2D- and 3D-representations for certain graph classes:

In 2D, we show that, for k-outerplanar graphs with n vertices, \(\varTheta (kn)\) pixels are always sufficient and sometimes necessary (see Sect. 3). In particular, outerplanar graphs can be represented with a linear number of pixels, whereas general planar graphs sometimes need a quadratic number.

In 3D, \(\varTheta (n^2)\) voxels are always sufficient and sometimes necessary for any n-vertex graph (see Sect. 4). We improve this bound to \(\varTheta (n\cdot \tau )\) for graphs of treewidth \(\tau \) and to \(O((g+1)^2n\log ^2n)\) for graphs of genus g. In particular, n-vertex planar graphs admit voxel representations with \(O(n\log ^2n)\) voxels.

2 Complexity

First, we show that it is NP-hard to compute minimum-size pixel representations. We reduce from the problem of deciding whether a planar graph of maximum degree 4 has a grid drawing with edges of length 1. This problem is known to be NP-hard [7]. The hardness proof still works if the angles between adjacent edges are specified. Note that specifying the angles also prescribes the circular order of edges around vertices (up to reversal). We can only sketch the hardness proof here, details are in the full paper [3].

Theorem 1

It is NP-complete to minimize the size of a pixel representation of a planar graph.

Fig. 1.
figure 1

A graph G drawn with length-1 edges and prescribed angles between adjacent edges, and the resulting graph H drawn with length-1 edges and pixel representation (in gray).

Proof Sketch

Clearly the decision problem is in NP. Let G be a planar graph of maximum degree 4 with prescribed angles between edges. Construct a graph H by replacing each vertex by a five-vertex wheel so that the angles between the edges are respected, and subdividing each edge except the ones incident to the wheel centers. Then G has a grid drawing with edge length 1 if and only if H has a representation where each vertex is a pixel. Indeed, from a grid drawing of G one can obtain a drawing of H where two vertices have distance 1 if and only if they are adjacent; see Fig. 1. Represent each vertex v of H by a pixel with v at its center. Conversely, if H has a representation where each vertex is a pixel, then for each vertex v of G, the subdivided wheel is a \(3\times 3\) square. Placing each vertex v at the center of the square and scaling by 1 / 4 yields the grid drawing of G.    \(\square \)

Next, we reduce computing minimum-size pixel representations to computing minimum-size voxel representations. In our reduction [3], we build a rigid structure around the given graph that forces the given graph to be drawn in a single plane.

Theorem 2

It is NP-complete to minimize the size of a voxel representation of a graph.

3 Lower and Upper Bounds in 2D

Here we only consider planar graphs since only planar graphs admit pixel representations. Let G be a planar graph with fixed plane embedding \(\mathscr {E}\). The embedding \(\mathscr {E}\) is 1-outerplane (or simply outerplane) if all vertices are on the outer face. It is k -outerplane if removing all vertices on the outer face yields a \((k-1)\)-outerplane embedding. A graph G is k -outerplanar if it admits a k-outerplane embedding but no \(k'\)-outerplane embedding for \(k' < k\). Note that \(k \in O(n)\), where n is the number of vertices of G.

In Sect. 3.1, we show that pixel representations of an n-vertex k-outerplanar graph sometimes requires \(\varOmega (kn)\) pixels. As the number of pixels is a lower bound for the area consumption, this strengthens a result by Dolev et al. [20] that says that orthogonal drawings of planar graphs of maximum degree 4 and width w sometimes require \(\varOmega (wn)\) area. As we will see later, width and k-outerplanarity are very similar concepts.

In Sect. 3.2, we show that O(kn) area and thus using O(kn) pixels is also sufficient. We use a result by Dolev et al. [20] who proved that any n-vertex planar graph of maximum degree 4 and width w admits a planar orthogonal drawing of area O(wn). The main difficulty is to extend their result to general planar graphs.

3.1 Lower Bound

Let G be a k-outerplanar graph with a pixel representation \(\varGamma \). Note that a pixel representation \(\varGamma \) induces an embedding of G. Let \(\varGamma \) induce a k-outerplane embedding of G, which we call a k -outerplane pixel representation for short. We claim that the width and the height of \(\varGamma \) are at least \(2k-1\). For \(k = 1\) this is trivial as every (non-empty) graph requires width and height at least 1. For \(k \ge 2\), let \(V_\mathrm {ext}= \{v_1, \dots , v_\ell \}\) be the set of vertices incident to the outer face of \(\varGamma \). Removing \(V_\mathrm {ext}\) from G yields a \((k-1)\)-outerplane graph \(G'\) with corresponding pixel representation \(\varGamma '\). By induction, \(\varGamma '\) requires width and height \(2(k-1) - 1\). As the representation of \(V_\mathrm {ext}\) in \(\varGamma \) encloses the whole representation \(\varGamma '\) in its interior, the width and the height of \(\varGamma \) are at least two units larger than the width and the height of \(\varGamma '\), respectively.

Clearly, the number of pixels required by the vertices in \(V_\mathrm {ext}\) is at least the perimeter of \(\varGamma \) (twice the width plus twice the height minus 4 for the corners, which are shared) and thus at least \(8k-8\). After removing the vertices in \(V_\mathrm {ext}\), the new vertices on the outer face require \(8(k-1)-8\) pixels, and so on. Thus, the representation \(\varGamma \) requires overall at least \(\sum _{i=1}^{k}(8i-8) = 4k^2 -4k\) pixels, which gives the following lemma.

Lemma 1

Any k-outerplane pixel representation has size at least \(4k^2-4k\).

There are k-outerplanar graphs with n vertices such that \(k \in \varTheta (n)\). For example, the nested triangle graph with 2k triangles (see Fig. 2) has \(n = 6k\) vertices and is k-outerplanar for \(k \ge 2\). Let G be a graph with c connected components each of which is k-outerplanar and has \(\varTheta (k)\) vertices. Then each connected component requires \(4k^2-4k\) pixels (due to Lemma 1) and thus we need at least \((4k^2-4k)c\) pixels in total. As G has \(n = \varTheta (kc)\) vertices, we get \((4k^2-4k)c \in \varTheta (kn)\), which proves the following.

Theorem 3

Some k-outerplanar graphs require \(\varOmega (kn)\)-size pixel representations.

3.2 Upper Bound

In the following two lemmas, we first show how to construct a pixel representation from a given orthogonal drawing and that taking minors does not heavily increase the number of pixels we need. Both lemmas aim at extending a result of Dolev et al. [20] on orthogonal drawings of planar graphs with maximum degree 4 to pixel representations of general planar graphs. As we re-use both lemmas in the 3D case (Sect. 4), we state them in the general d-dimensional setting.

Lemma 2

Let G be a graph with n vertices, m edges, and an orthogonal drawing of total edge length \(\ell \) in d-dimensional space. Then G admits a d-dimensional representation of size \(2\ell + n - m\).

Proof

We first scale the given drawing \(\varGamma \) of G by a factor of 2 and subdivide the edges of G such that every edge has length 1. Denote the resulting graph by \(G'\) and its drawing by \(\varGamma '\). An edge e of length \(\ell _e\) in \(\varGamma \) is represented by a path with \(2\ell _e - 1\) internal vertices (the subdivision vertices). Thus, the total number of subdivision vertices is \(2\ell - m\). Due to the scaling, non-adjacent vertices in \(G'\) have distance greater than 1 in \(\varGamma '\) (adjacent vertices have distance 1). Thus, representing every vertex v by the box having v as center yields a representation of \(G'\) with \(2\ell + n - m\) boxes (one box per vertex of \(G'\)). If we assign the boxes representing subdivision vertices to one of the endpoints of the corresponding edge, we get a representation of G with \(2\ell + n - m\) boxes.    \(\square \)

Fig. 2.
figure 2

A nested triangle graph of outerplanarity \(\varOmega (n)\).

Fig. 3.
figure 3

Constructing a representation of a minor with asymptotically the same number of blocks.

Lemma 3

Let G be a graph that has a d-dimensional representation of size b. Every minor of G admits a d-dimensional representation of size at most \(3^d b\).

Proof

Let H be a minor obtained from G by first deleting some edges, then deleting isolated vertices, and finally contracting edges. We start with the representation \(\varGamma \) of G using b boxes and scale it by a factor of 3. This yields a representation \(3\varGamma \) using \(3^db\) boxes. Then we modify \(3\varGamma \), without adding boxes, to represent the minor H. For convenience, we consider the 2D case; the case \(d > 2\) works analogously.

Let uv be an edge in G that is deleted. In \(3\varGamma \) we delete every pixel in the representation of u that touches a pixel of the representation of v. We claim that this neither destroys the contact of u with any other vertex nor does it disconnect the shape representing u. Consider a single pixel B in \(\varGamma \). In \(3\varGamma \) it is represented by a square of \(3\times 3\) pixels belonging to B. If B is in contact to another pixel A in \(\varGamma \), then there is a pair of pixels \(A'\) and \(B'\) in \(3\varGamma \) such that \(A'\) and \(B'\) are in contact, while all other pixels that touch \(A'\) and \(B'\) belong to A and B, respectively; see Fig. 3a and b. Assume that we remove in \(3\varGamma \) all pixels belonging to B that are in contact to pixels belonging to another pixel C touching B in \(\varGamma \); see Fig. 3c. Obviously, this does not effect the contact between \(A'\) and \(B'\). Moreover, the remaining pixels belonging to B form a connected blob. The above claim follows immediately.

Removing isolated vertices can be done by simply removing their representation. Moreover, contracting an edge uv into a vertex w can be done by merging the blobs representing u and v into a single blob representing w. This blob is obviously connected and touches the blob of another vertex if and only if either u or v touch this vertex.    \(\square \)

Now let G be a k-outerplanar graph. Applying the algorithm of Dolev et al. [20] yields an orthogonal drawing of total length O(wn), where w is the width of G. The width w of G is the maximum number of vertices contained in a shortest path from an arbitrary vertex of G to a vertex on the outer face. Given the orthogonal drawing, Lemma 2 gives us a pixel representation of G. There are, however, two issues. First, k and w are not the same (e.g., subdividing edges increases w but not k). Second, G does not have maximum degree 4, thus we cannot simply apply the algorithm of Dolev et al. [20].

Concerning the first issue, we note that the algorithm of Dolev et al. exploits that G has width w only to find a special type of separator [20, Theorem 1]. For this, it is sufficient that G is a subgraph of a graph of width w (not necessarily with maximum degree 4; in fact Dolev et al. triangulate the graph before finding the separator).

Lemma 4

Every k-outerplanar graph has a planar supergraph of width \(w = k\).

Proof

Let G be a graph with a k-outerplane embedding. Iteratively deleting the vertices on the outer face gives us a sequence of deletion phases. For each vertex v, let \(k_v\) be the phase in which v is deleted. Note that the maximum over all values of \(k_v\) is exactly k. For any vertex v, either \(k_v = 1\) or there is a vertex u with \(k_u=k_v-1\) such that u and v are incident to a common face. Thus, there is a sequence \(v_1, \dots , v_{k_v}\) of \(k_v\) vertices such that (i) \(v_1 = v\), (ii) \(v_{k_v}\) lies on the outer face, and (iii) \(v_i\), \(v_{i+1}\) are incident to a common face. If the graph G was triangulated, this would yield a path containing \(k_v\) vertices from v to a vertex on the outer face. Thus, triangulated k-outerplanar graphs have width \(w = k\).

It remains to show that G can be triangulated without increasing \(k_v\) for any vertex v. Consider a face f and let u be the vertex incident to f for which \(k_u\) is minimal. Let \(v\not =u\) be any other vertex incident to f. Adding the edge uv clearly does not increase the value \(k_x\) for any vertex x. We add edges in this way until the graph is triangulated. Alternatively, we can use a result of Biedl [8] to triangulate G. Note that we do not need to triangulate the outer face of G. Hence, we do not increase the outerplanarity.    \(\square \)

To solve the second issue (the k-outerplanar graph G not having maximum degree 4), we construct a graph \(G'\) such that G is a minor of \(G'\), \(G'\) is k-outerplanar, and \(G'\) has maximum degree 4. Then, (due to Lemma 4) we can apply the algorithm of Dolev et al. [20] to \(G'\). Next, we apply Lemma 2 to the resulting drawing to get a representation of \(G'\) with O(kn) pixels. As G is a minor of \(G'\), Lemma 3 yields a representation of G that, too, requires O(kn) pixels.

Theorem 4

Every k-outerplanar n-vertex graph has a size O(kn) pixel representation.

Proof

Let G be a k-outerplanar graph. After the above considerations, it remains to construct a k-outerplanar graph \(G'\) with maximum degree 4 such that G is a minor of \(G'\). Let u be a vertex with \(\deg (u) > 4\). We replace u with a path of length \(\deg (u)\) and connect each neighbor of u to a unique vertex of this path. This can be done maintaining a plane embedding. We now show that the resulting graph remains k-outerplanar.

Fig. 4.
figure 4

Replacement of high-degree vertices while preserving k-outerplanarity.

Consider a vertex u on the outer face with neighbors \(v_1, \dots , v_\ell \). Assume the neighbors appear in that order around u such that \(v_1\) is the counter-clockwise successor of u on the outer face; see Fig. 4. We replace u with the path \(u_1, \dots , u_\ell \) and connect \(u_i\) to \(v_i\) for \(1 \le i \le \ell \). Call the resulting graph \(G_u\). Note that all \(u_i\) in \(G_u\) are incident to the outer face. Thus, if G was k-outerplanar, \(G_u\) is also k-outerplanar. Moreover, the degrees of the new vertices do not exceed 4 (actually not even 3), and G is a minor of \(G_u\)—one can simply contract the inserted path to obtain G.

We can basically apply the same replacement if u is not incident to the outer face. Assume that we delete u in phase \(k_u\) if we iteratively delete vertices incident to the outer face. When replacing u with the vertices \(u_1, \dots , u_\ell \), we have to make sure that all these vertices get deleted in phase \(k_u\). Let f be a face incident to u that is merged with the outer face after \(k_u - 1\) deletion phases (such a face must exist, otherwise u is not deleted in phase \(k_u\)). We apply the same replacement as for the case where u was incident to the outer face, but this time we ensure that the new vertices \(u_i\) are incident to the face f. Thus, after \(k_u - 1\) deletion phases they are all incident to the outer face and thus they are deleted in phase \(k_u\). Hence, the resulting graph \(G_u\) is k-outerplanar. Again the new vertices have degree at most 3 and G is obviously a minor of \(G_u\). Iteratively applying this kind of replacement for every vertex u with \(\deg (u) > 4\) yields the claimed graph \(G'\).

The corresponding drawing can then be obtained as follows. Since \(G'\) has a supergraph of width \(w=k\) by Lemma 4, and \(G'\) has maximum degree 4, we use the algorithm of Dolev et al. [20] to obtain a drawing of \(G'\) with area (and hence total edge length) O(nk). By Lemma 2, we thus obtain a representation of \(G'\) with O(nk) pixels. Since G is a minor of \(G'\), Lemma 3 yields a representation of G with O(nk) pixels.    \(\square \)

4 Representations in 3D

In this section, we consider voxel representations. We start with some basic considerations showing that every n-vertex graph admits a representation with \(O(n^2)\) voxels. Note that \(\varOmega (n^2)\) is obviously necessary for \(K_n\) as every edge corresponds to a face-to-face contact and every voxel has at most 6 such contacts. We improve on this simple general result in two ways. First, we show that n-vertex graphs with treewidth at most \(\tau \) admit voxel representations of size \(O(n\cdot \tau )\) (see Sect. 4.1). Second, for n-vertex graphs with genus at most g, we obtain representations with \(O(g^2n\log ^2 n)\) voxels (see Sect. 4.2).

Theorem 5

Any n-vertex graph admits a voxel representation of size \(O(n^2)\).

Proof

Let G be a graph with vertices \(v_1, \dots , v_n\). Vertex \(v_i\) (\(i=1,\dots ,n\)) is represented by three cuboids (see Fig. 5a), namely a vertical cuboid consisting of the voxels centered at the points \((2i, 2, 0), (2i, 3, 0), \dots , (2i, 2n, 0)\), a horizontal cuboid consisting of the voxels centered at \((2, 2i, 2), (3, 2i, 2), \dots , (2n, 2i, 2)\), and the voxel centered at (2i, 2i, 1). This yields a representation where every vertex is a connected blob and no two blobs are in contact. Moreover, for every pair of vertices \(v_i\) and \(v_j\), there is a voxel of \(v_i\) at (2i, 2j, 0) and a voxel of \(v_j\) at (2i, 2j, 2) and no voxel between them at (2i, 2j, 1). Thus, one can easily represent an arbitrary edge \((v_i, v_j)\) by extending the representation of \(v_i\) to also contain (2i, 2j, 1); see Fig. 5b. Clearly, this representation consists of \(O(n^2)\) voxels.    \(\square \)

Fig. 5.
figure 5

(a) The basic contact representation without any contacts between vertices. (b) If \(v_1\) and \(v_4\) are adjacent, it suffices to add a single voxel to the representation of \(v_1\) (or to that of \(v_4\)).

4.1 Graphs of Bounded Treewidth

Let \(G = (V, E)\) be a graph. A tree decomposition of G is a tree T where each node \(\mu \) in T is associated with a bag \(X_\mu \subseteq V\) such that: (i) for each \(v \in V\), the nodes of T whose bags contain v form a connected subtree, and (ii) for each edge \(uv \in E\), T contains a node \(\mu \) such that \(u, v\in X_\mu \).

Note that we use (lower case) Greek letters for the nodes of T to distinguish them from the vertices of G. The width of the tree decomposition is the maximum bag size minus 1. The treewidth of G is the minimum width over all tree decompositions of G. A tree decomposition is nice if T is a rooted binary tree, where for every node \(\mu \):

  • \(\mu \) is a leaf and \(|X_\mu | = 1\) (leaf node), or

  • \(\mu \) has a single child \(\eta \) with \(X_\mu \subseteq X_\eta \) and \(|X_\mu | = |X_\eta | - 1\) (forget node), or

  • \(\mu \) has a single child \(\eta \) with \(X_\eta \subseteq X_\mu \) and \(|X_\mu | = |X_\eta | + 1\) (introduce node), or

  • \(\mu \) has two children \(\eta \) and \(\kappa \) with \(X_\mu = X_\eta = X_\kappa \) (join node).

Any tree decomposition can be transformed (without increasing its width) into a nice tree decomposition such that the resulting tree T has O(n) nodes, where n is the number of vertices of G [10]. This transformation can be done in linear time. Thus, we can assume any tree decomposition to be a nice tree decomposition with a tree of size O(n).

Lemma 5

Let T be a nice tree decomposition of a graph G. The edges of G can be mapped to the nodes of T such that every edge uv of G is mapped to a node \(\mu \) with \(u, v \in X_\mu \) and the edges mapped to each node \(\mu \) form a star.

Proof

We say that a node \(\mu \) represents the edge uv if uv is mapped to \(\mu \). Consider a node \(\mu \) during a bottom-up traversal of T. We want to maintain the invariant that, after processing \(\mu \), all edges between vertices in \(X_\mu \) are represented by \(\mu \) or by a descendant of \(\mu \). This ensures that every edge is represented by at least one node. Every edge can then be mapped to one of the nodes representing it.

If \(\mu \) is a leaf, it cannot represent an edge as \(|X_\mu | = 1\). If \(\mu \) is a forget node, it has a child \(\eta \) with \(X_\mu \subseteq X_\eta \). Thus, by induction, all edges between vertices in \(X_\mu \) are already represented by descendants of \(\mu \). If \(\mu \) is an introduce node, it has a child \(\eta \) and \(X_\mu = X_\eta \cup \{u\}\) for a vertex u of G. By induction, all edges between nodes in \(X_\eta \) are already represented by descendants of \(\mu \). Thus, \(\mu \) only needs to represent the edges between the new node u and other nodes in \(X_\mu \). Note that these edges form a star with center u. Finally, if \(\mu \) is a join node, no edge needs to be represented by \(\mu \) (by the same argument as for forget nodes). This concludes the proof.    \(\square \)

We obtain a small voxel representation of G from a nice tree decomposition T of G of treewidth \(\tau \) roughly as follows. We start with a “2D” voxel representation of the tree T, that is, all voxel centers lie in the xy plane. We take \(\tau + 1\) copies of this representation and place them in different layers in 3D space. We then assign to each vertex v of G a piece of this layered representation such that its piece contains all nodes of T that include v in their bags. For an edge uv, let \(\mu \) be the node to which uv is mapped by Lemma 5. By construction, the representation of \(\mu \) occurs multiple times representing u and v in different layers. To represent uv, we only have to connect the representations of u and v. As it suffices to represent a star for each node \(\mu \) in this way, the number of voxels additionally used for these connections is small.

Theorem 6

Any n-vertex graph of treewidth \(\tau \) has a voxel representation of size \(O(n\tau )\).

Proof

Let G be an n-vertex graph of treewidth \(\tau \). During our construction, we will get some contacts between the blobs of vertices that are actually not adjacent in G. As G is a minor of the graph that we represent this way, we can use Lemma 3 to get a representation of G. Let T be a nice tree decomposition of G. As a tree, T is outerplanar and, hence, admits a pixel representation \(\varGamma \) with O(n) pixels (by Theorem 4). Let \(\varGamma _1,\dots ,\varGamma _k\) be voxel representations corresponding to \(\varGamma \) with z-coordinates \(1,\dots , k = \tau + 1\).

For a vertex v of G, we denote by \(\varGamma _i(v)\) the sub-representation of \(\varGamma _i\) induced by the nodes of T whose bags contain v. Now let \(c :V \rightarrow \{1, \dots , k\}\) be a k-coloring of G with color set \(\{1,\dots ,k\}\) such that no two vertices sharing a bag have the same color. Such a coloring can be computed by traversing T bottom up, assigning in every introduce node \(\mu \) a color to the new vertex that is not already used by any other vertex in \(X_\mu \). As a basis for our construction, we represent each vertex v of G by the sub-representation \(\varGamma _{c(v)}(v)\).

So far, we did not represent any edge of G. Our construction, however, has the following properties: (i) it uses O(nk) voxels. (ii) every vertex is a connected set of voxels. (iii) for every node \(\mu \) of T, there is a position \((x_\mu , y_\mu )\) in the plane such that, for every vertex \(v \in X_\mu \), the voxel at \((x_\mu , y_\mu , c(v))\) belongs to the representation of v. Scaling the representation by a factor of 2 ensures that this is not the only voxel for v and that v is not disconnected if this voxel is removed (or reassigned to another vertex).

By Lemma 5 it suffices to represent for every node \(\mu \) edges between vertices in \(X_\mu \) that form a star. Let u be the center of this star. We simply assign the voxels centered at \((x_\mu , y_\mu , 1), \dots , (x_\mu , y_\mu , k)\) to the blob of u. This creates a contact between u and every other vertex \(v \in X_\mu \) (by the above property that the voxel \((x_\mu , y_\mu , c(v))\) belonged to v before). Finally, we apply Lemma 3 to get rid of unwanted contacts. The resulting representation uses O(nk) voxels, which concludes the proof.    \(\square \)

Note that cliques of size k require \(\varOmega (k^2)\) voxels. Taking the disjoint union of n / k such cliques yields graphs with n vertices requiring \(\varOmega (nk)\) voxels. Note that these graphs have treewidth \(\tau = k - 1\). Thus, the bound of Theorem 6 is asymptotically tight.

Theorem 7

Some n-vertex graphs of treewidth \(\tau \) require \(\varOmega (n\tau )\) voxels.

4.2 Graphs of Bounded Genus

Since planar graphs (genus 0) have treewidth \(O(\sqrt{n})\) [27], we can obtain a voxel representation of size \(O(n^{1.5})\) for any planar graph, from Theorem 6. Next, we improve this bound to \(O(n \log ^2 n)\) by proving a more general result for graphs of bounded genus. Recall that we used known results on orthogonal drawings with small area to obtain small pixel representations in Sect. 3.2. Here we follow a similar approach (re-using Lemmas 2 and 3), now allowing the orthogonal drawing we start with to be non-planar.

We obtain small voxel representations by first showing that it is sufficient to consider graphs of maximum degree 4: we replace higher-degree vertices by connected subgraphs as in the proof of Theorem 4. Then we use a result of Leiserson [33] who showed that any graph of genus g and maximum degree 4 admits a 2D orthogonal drawing of area \(O((g+1)^2 n \log ^2n)\), possibly with edge crossings. The area of an orthogonal drawing is clearly an upper bound for its total edge length. Finally we turn the pixels into voxels and use the third dimension to get rid of the crossings without using too many additional voxels.

Theorem 8

Every n-vertex graph of genus g admits a voxel representation of size \(O((g+1)^2 n \log ^2n)\).

Proof

Let G be an n-vertex graph, and let u be a vertex of degree \(\ell > 4\). Assume G to be embedded on a surface of genus g, and let \(v_1, \dots , v_\ell \) be the neighbors of u appearing in that order around u (with respect to the embedding). We replace u with the cycle \(u_1, \dots , u_\ell \) and connect \(u_i\) to \(v_i\) for \(1 \le i \le \ell \); see Fig. 6a. Clearly, the new vertices have degree 3 and the genus of the graph has not increased. Applying this modification to every vertex of degree at least 5 yields a graph \(G_4\) of maximum degree 4 and genus g. Moreover, G is a minor of \(G_4\) as one can undo the cycle replacements by contracting all edges in the cycles. Thus, we can transform a voxel representation of \(G_4\) into a voxel representation of G by applying Lemma 3.

We claim that the number \(n_4\) of vertices in \(G_4\) is linear in n. Indeed, if m denotes the number of edges in G, then we have \(n_4 \le n + 2m\). Moreover, we can assume without loss of generality that \(g \in O(n)\) (otherwise Theorem 5 already gives a better bound). This implies that \(m \in O(n)\) and hence, \(n_4 \in O(n)\), as we claimed.

We thus assume that G has maximum degree 4. Then G has a (possibly non-planar) orthogonal drawing \(\varGamma \) of total edge length \(O(g^2 n \log ^2n)\) [33]. We modify G and \(\varGamma \) as follows. For every bend on an edge e in \(\varGamma \), we subdivide the edge e once yielding a partition of the edges of the subdivided graph into horizontal and vertical edges. We obtain a graph \(G'\) from this subdivision of G by replacing every vertex v by two adjacent vertices \(v_1\) and \(v_2\), and connecting \(v_1\) and \(w_1\) (respectively \(v_2\) and \(w_2\)) by an edge if v and w are connected by a horizontal (respectively vertical edge); see Fig. 6b.

Fig. 6.
figure 6

Constructing voxel representations for bounded-genus graphs: (a) replacing high-degree vertices while preserving the genus, (b) subdividing and decomposing a graph according to a non-planar orthogonal drawing with small area, and (c) constructing a 3D drawing with small total edge length from the decomposition in (b).

We draw \(G'\) in 3D space by using the drawing \(\varGamma \) and setting for every vertex v the z-coordinate of \(v_1\) and \(v_2\) to 0 and 1, respectively. The x- and y-coordinates of vertices and edges are the same as in \(\varGamma \); see Fig. 6b. Note that G is a minor of \(G'\): we obtain G from \(G'\) by contracting (i) the edge \(v_0v_1\) for every vertex v and (ii) any subdivision vertex. Asymptotically, the total edge length of \(\varGamma '\) is the same as that of \(\varGamma \), that is, \(O((g+1)^2 n \log ^2n)\). By Lemma 2, we turn \(\varGamma '\) into a voxel representation of \(G'\) and, by Lemma 3, into a voxel representation of G with size \(O((g+1)^2 n \log ^2n)\).    \(\square \)

5 Conclusion

In this paper, we have studied pixel representations and voxel representations of graphs, where vertices are represented by disjoint blobs (that is, connected sets of grid cells) and edges correspond to pairs of blobs with face-to-face contact. We have shown that it is NP-complete to minimize the number of pixels or voxels in such representations. Does this problem admit an approximation algorithm?

We have shown that \(O((g+1)^2n \log ^2n)\) voxels suffice for any n-vertex graph of genus g. It remains open to improve this upper bound or to give a non-trivial lower bound. We believe that any planar graph admits a voxel representation of linear size.