Pixel and Voxel Representations of Graphs

  • Md. Jawaherul Alam
  • Thomas Bläsius
  • Ignaz Rutter
  • Torsten Ueckerdt
  • Alexander WolffEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9411)


We study contact representations for graphs, which we call pixel representations in 2D and voxel representations in 3D. Our representations are based on the unit square grid whose cells we call pixels in 2D and voxels in 3D. Two pixels are adjacent if they share an edge, two voxels if they share a face. We call a connected set of pixels or voxels a blob. Given a graph, we represent its vertices by disjoint blobs such that two blobs contain adjacent pixels or voxels if and only if the corresponding vertices are adjacent. We are interested in the size of a representation, which is the number of pixels or voxels it consists of.

We first show that finding minimum-size representations is NP-complete. Then, we bound representation sizes needed 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. 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. 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, planar graphs admit representations with \(O(n\log ^2n)\) voxels.


Planar Graph Maximum Degree Tree Decomposition Outer Face Contact Representation 
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.

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\).


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.

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

Fig. 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\).


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\).


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.


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.

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)\).


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.

(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.


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 )\).


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)\).


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.

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.


  1. 1.
    Aerts, N., Felsner, S.: Vertex contact graphs of paths on a grid. In: Kratsch, D., Todinca, I. (eds.) WG 2014. LNCS, vol. 8747, pp. 56–68. Springer, Heidelberg (2014) Google Scholar
  2. 2.
    Alam, M.J., Biedl, T., Felsner, S., Kaufmann, M., Kobourov, S., Ueckerdt, T.: Computing cartograms with optimal complexity. Discrete Comput. Geom. 50(3), 784–810 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Alam, M.J., Bläsius, T., Rutter, I., Ueckerdt, T., Wolff, A.: Pixel and voxel representations of graphs. Arxiv report (2015).
  4. 4.
    Badent, M., Binucci, C., Di Giacomo, E., Didimo, W., Felsner, S., Giordano, F., Kratochvíl, J., Palladino, P., Patrignani, M., Trotta, F.: Homothetic triangle contact representations of planar graphs. In: Canadian Conference on Computational Geometry (CCCG 2007), pp. 233–236 (2007)Google Scholar
  5. 5.
    Bezdek, A.: On the number of mutually touching cylinders. Comb. Comput. Geom. 52, 121–127 (2005)MathSciNetGoogle Scholar
  6. 6.
    Bezdek, K., Reid, S.: Contact graphs of unit sphere packings revisited. J. Geom. 104(1), 57–83 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  7. 7.
    Bhatt, S.N., Cosmadakis, S.S.: The complexity of minimizing wire lengths in VLSI layouts. Inform. Process. Lett. 25(4), 263–267 (1987)CrossRefzbMATHGoogle Scholar
  8. 8.
    Biedl, T.: On triangulating \(k\)-outerplanar graphs. Discrete Appl. Math. 181, 275–279 (2015). MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Biedl, T.C.: Small drawings of outerplanar graphs, series-parallel graphs, and other planar graphs. Discrete Comput. Geom. 45(1), 141–160 (2011)MathSciNetCrossRefzbMATHGoogle Scholar
  10. 10.
    Bodlaender, H.L.: Treewidth: algorithmic techniques and results. In: Prívara, I., Ružička, P. (eds.) MFCS 1997. LNCS, vol. 1295, pp. 19–36. Springer, Heidelberg (1997) CrossRefGoogle Scholar
  11. 11.
    Bose, P., Everett, H., Fekete, S.P., Houle, M.E., Lubiw, A., Meijer, H., Romanik, K., Rote, G., Shermer, T.C., Whitesides, S., Zelle, C.: A visibility representation for graphs in three dimensions. J. Graph Algorithms Appl. 2(3), 1–16 (1998)MathSciNetCrossRefGoogle Scholar
  12. 12.
    Brandenburg, F.J., Eppstein, D., Goodrich, M.T., Kobourov, S.G., Liotta, G., Mutzel, P.: Selected open problems in graph drawing. In: Liotta, G. (ed.) GD 2003. LNCS, vol. 2912, pp. 515–539. Springer, Heidelberg (2004) CrossRefGoogle Scholar
  13. 13.
    Brandenburg, F.J.: 1-visibility representations of 1-planar graphs. J. Graph Algorithms Appl. 18(3), 421–438 (2014)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Bremner, D., et al.: On representing graphs by touching cuboids. In: Didimo, W., Patrignani, M. (eds.) GD 2012. LNCS, vol. 7704, pp. 187–198. Springer, Heidelberg (2013) CrossRefGoogle Scholar
  15. 15.
    Buchsbaum, A.L., Gansner, E.R., Procopiuc, C.M., Venkatasubramanian, S.: Rectangular layouts and contact graphs. ACM Trans. Algorithms 4(1), 8–28 (2008)MathSciNetCrossRefGoogle Scholar
  16. 16.
    Cano, R., Buchin, K., Castermans, T., Pieterse, A., Sonke, W., Speckmann, B.: Mosaic drawings and cartograms. Comput. Graph. Forum 34(3), 361–370 (2015)CrossRefGoogle Scholar
  17. 17.
    Chan, T.M., Goodrich, M.T., Kosaraju, S.R., Tamassia, R.: Optimizing area and aspect ratio in straight-line orthogonal tree drawings. Comput. Geom. Theory Appl. 23(2), 153–162 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Chaplick, S., Kobourov, S.G., Ueckerdt, T.: Equilateral L-contact graphs. In: Brandstädt, A., Jansen, K., Reischuk, R. (eds.) WG 2013. LNCS, vol. 8165, pp. 139–151. Springer, Heidelberg (2013) CrossRefGoogle Scholar
  19. 19.
    Di Battista, G., Frati, F.: Small area drawings of outerplanar graphs. Algorithmica 54(1), 25–53 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  20. 20.
    Dolev, D., Leighton, T., Trickey, H.: Planar embedding of planar graphs. Adv. Comput. Res. 2, 147–161 (1984)Google Scholar
  21. 21.
    Dujmović, V., Morin, P., Wood, D.: Layered separators for queue layouts, 3d graph drawing and nonrepetitive coloring. In: Foundations of Computer Science (FOCS 2013), pp. 280–289. IEEE (2013)Google Scholar
  22. 22.
    Duncan, C.A., Gansner, E.R., Hu, Y.F., Kaufmann, M., Kobourov, S.G.: Optimal polygonal representation of planar graphs. Algorithmica 63(3), 672–691 (2012)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Evans, W., Kaufmann, M., Lenhart, W., Mchedlidze, T., Wismath, S.: Bar 1-visibility graphs and their relation to other nearly planar graphs. J. Graph Algorithms Appl. 18(5), 721–739 (2014)MathSciNetCrossRefzbMATHGoogle Scholar
  24. 24.
    Fan, J.-H., Lin, C.-C., Lu, H.-I., Yen, H.-C.: Width-optimal visibility representations of plane graphs. In: Tokuyama, T. (ed.) ISAAC 2007. LNCS, vol. 4835, pp. 160–171. Springer, Heidelberg (2007) CrossRefGoogle Scholar
  25. 25.
    Felsner, S.: Rectangle and square representations of planar graphs. Thirty Essays on Geometric Graph Theory, pp. 213–248 (2013)Google Scholar
  26. 26.
    Felsner, S., Francis, M.C.: Contact representations of planar graphs with cubes. In: Symposium on Computational Geometry (SoCG 2011), pp. 315–320. ACM (2011)Google Scholar
  27. 27.
    Fomin, F.V., Thilikos, D.M.: New upper bounds on the decomposability of planar graphs. J. Graph Theory 51(1), 53–81 (2006)MathSciNetCrossRefGoogle Scholar
  28. 28.
    de Fraysseix, H., de Mendez, P.O.: Representations by contact and intersection of segments. Algorithmica 47(4), 453–463 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  29. 29.
    de Fraysseix, H., de Mendez, P.O., Rosenstiehl, P.: On triangle contact graphs. Comb. Prob. Comput. 3, 233–246 (1994)CrossRefzbMATHGoogle Scholar
  30. 30.
    de Fraysseix, H., Pach, J., Pollack, R.: How to draw a planar graph on a grid. Combinatorica 10(1), 41–51 (1990)MathSciNetCrossRefzbMATHGoogle Scholar
  31. 31.
    Hliněný, P., Kratochvíl, J.: Representing graphs by disks and balls (a survey of recognition-complexity results). Discrete Math. 229(1–3), 101–124 (2001)MathSciNetCrossRefzbMATHGoogle Scholar
  32. 32.
    Koebe, P.: Kontaktprobleme der konformen Abbildung. Berichte über die Verhandlungen der Sächsischen Akademie der Wissenschaften zu Leipzig. Math. Phy. Kla. 88, 141–164 (1936)Google Scholar
  33. 33.
    Leiserson, C.E.: Area-efficient graph layouts (for VLSI). In: Foundations of Computer Science (FOCS 1980), pp. 270–281. IEEE (1980)Google Scholar
  34. 34.
    Pach, J., Thiele, T., Tóth, G.: Three-dimensional grid drawings of graphs. In: Di Battista, G. (ed.) GD 1997. LNCS, vol. 1353, pp. 47–51. Springer, Heidelberg (1997) CrossRefGoogle Scholar
  35. 35.
    Patrignani, M.: Complexity results for three-dimensional orthogonal graph drawing. J. Discrete Algorithms 6(1), 140–161 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  36. 36.
    Schnyder, W.: Embedding planar graphs on the grid. In: Symposium on Discrete Algorithms (SODA 1990), pp. 138–148. ACM-SIAM (1990)Google Scholar
  37. 37.
    Tamassia, R., Tollis, I.G.: A unified approach a visibility representation of planar graphs. Discrete Comput. Geom. 1, 321–341 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  38. 38.
    Thomassen, C.: Interval representations of planar graphs. J. Comb. Theory B 40(1), 9–20 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  39. 39.
    Zong, C.: The kissing numbers of tetrahedra. Discrete Comput. Geom. 15(3), 239–252 (1996)MathSciNetCrossRefzbMATHGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  • Md. Jawaherul Alam
    • 1
  • Thomas Bläsius
    • 2
  • Ignaz Rutter
    • 2
  • Torsten Ueckerdt
    • 2
  • Alexander Wolff
    • 3
    Email author
  1. 1.University of ArizonaTucsonUSA
  2. 2.Karlsruhe Institute of TechnologyKarlsruheGermany
  3. 3.Universität WürzburgWürzburgGermany

Personalised recommendations