1 Introduction

Hypergraphs are a powerful structure to represent unordered set systems. In general, there are a number of elements (vertices of the hypergraph) and a number of different subsets over these elements (the hyperedges of the graph). The purpose of visualizing hypergraphs is to clarify the various set relations between the hyperedges. There are, roughly speaking, two strands of hypergraph visualizations: those where the position of the elements is fixed (e.g. [2, 7, 8, 15]), and those where the positions can be chosen by the layout algorithm (e.g. [10, 18, 19]). For a more detailed overview and in-depth classification of set visualization methods we refer to the survey by Alsallakh et al. [4]. Though some methods aim to overcome layout complexity by replicating elements (e.g. [3, 10]), we focus on a visualization using a single representation for each element.

In theoretic research on drawing hypergraphs (e.g. [6, 12]), the (often implicit) assumption is that the representations of two sets may cross at common vertices. Such crossings are not deemed problematic as most visual encodings rely on the local nesting of intersecting polygons (in line with the prototypical Venn and Euler diagrams [5] and similar visual overlays [7, 8, 15]) to identify set memberships. Nesting, however, gives a strong visual cue of containment and may result in misleading visual representations implying containment relationships between hyperedges. A rendering style without nesting is one suggested for Kelp Diagrams [8]. However, its cluttered appearance caused it not to feature in the later extension, KelpFusion [15].

One of the most well-established quality criteria of graph drawings is planarity (see e.g. [16, 17]). When nested encodings are used, a planar drawing relates to finding a planar support [6]: a planar (regular) graph such that the vertices of each hyperedge induce a connected subgraph in the support. Deciding whether a planar support exists is possible for some simple support classes (see [6] for a discussion), but is already NP-hard for 2-outerplanar support graphs [6]. Optimizing hypergraph supports for total graph length without planarity constraints is NP-hard, but approximation algorithms exist [1, 11].

Representations that do not require nesting are edge-based drawings [13] or the equivalent Zykov representation [22], for which notions of planarity follow readily from the standard notion for regular graphs.

Fig. 1.
figure 1

A hypergraph that is not Zykov-planar (top) but has a disjoint-polygons drawing (bottom).

Instead we suggest a visual design that uses disjoint polygons to present hyperedges: vertices are represented as simple geometric primitives (e.g. a square or circle); hyperedges are represented as connected polygons that overlaps only and all its incident vertices; and all such polygons are pairwise disjoint. As illustrated in Fig. 1, our disjoint-polygons encoding is stronger as it can visualize some hypergraphs that are not Zykov-planar, whereas any Zykov-planar hypergraph admits a disjoint-polygons representation. We can use vertices to “pass in between” the representations of other hyperedges, though not as flexibly as is allowed for planar supports: the polygons must remain disjoint.

Contributions. We investigate the properties of drawing hypergraphs using disjoint polygons. Motivated by moving towards a set visualization in a geographic small multiples or grid map (see e.g. [14, 23]), we specifically study the variant where each element has a fixed location, being a cell in a rectangular grid. As an initial exploration we focus on the 2-color case, where each cell is either red, blue, both (purple), or uncolored (white). We thus aim to partition each purple cell into red and blue pieces, such that the resulting pieces of a single color form a connected polygon. We derive a necessary and sufficient condition to efficiently recognize whether an instance is solvable. For solvable instances, we bound the number of colored pieces within each cell by a small constant and show that these bounds are tight. Due to space constraints, some proofs have been shortened or omitted; for full proofs, please refer to the ArXiv version [21].

2 Preliminaries

We define a k-colored grid \(\varGamma \) as a rectangular grid, in which each cell s has a set of associated colors \(\chi _s \subseteq \{1,\ldots ,k\}\). A fully k-colored grid is the case where \(\chi _s \ne \varnothing \) for all cells s. Throughout this paper, we primarily investigate 2-colored grids and use colored grid to refer to the 2-colored case, unless indicated otherwise. We refer to the two colors as (r)ed and (b)lue; cells for which \(\chi _s = \{r,b\}\) are called (p)urple. Cells with no associated colors are white.

A region is a maximal set of cells that have the same color assignment (r, b, or p) and where every cell s in the region is connected via adjacent cells to every other cell \(s'\) in the region. Cells are considered adjacent if they are horizontally or vertically adjacent.

A panel \(\pi _s\) for cell s (with \(\chi _s \ne \varnothing \)) maps each color \(c \in \chi _s\) to a (possibly disconnected) area \(\pi _s(c)\) such that these partition the cell: that is, \(\bigcup _{c \in \chi _s} \pi _s(c) = s\) and \(\pi _s(c_1) \cap \pi _s(c_2) = \varnothing \) for colors \(c_1 \ne c_2\). A painting \(\varPi \) of a k-colored grid consists of panels \(\pi _s\) for each cell s with \(\pi _s(c)\not =\varnothing \) for each \(c \in \chi _s\) and \(\pi _s(c) = \varnothing \) otherwise. We call a painting connected if each color forms a connected polygon: that is, \(\bigcup _{s\in \varGamma } \pi _s(c)\) is a connected polygon for each color \(c \in \{1,\ldots ,k\}\). For this definition, two cells sharing only a corner are not considered connected. Our primary interest is in connected paintings: in the remainder, we use painting to indicate a connected painting.

3 Characterizing Colored Grids with a Painting

In this section we show how to test whether a 2-colored grid admits a painting and how to find a painting if one exists. As all completely red, blue, and white panels are fixed, finding a painting reduces to finding partitions of purple cells that ensure that the resulting red and blue polygon are connected. We show that this connectivity is of key importance: if we can find suitable connections though the purple regions, then we can also create a partition that results in a valid panel for each cell in the purple regions.

We capture the connectivity options for the red and blue polygon using two embedded graphs, \(G_r\) and \(G_b\). We construct these graphs in three steps:

  1. 1.

    Connect red (blue) regions that are adjacent along a purple region’s boundary.

  2. 2.

    Remove holes from the purple regions by inserting connections (Sect. 3.3).

  3. 3.

    Construct \(G_r\) and \(G_b\) using a gadget for purple regions (Sects. 3.1 and 3.2).

For the first step, observe that consecutive (not necessarily distinct) adjacent regions of the same color can always be safely connected via the purple region’s boundary without restricting the connectivity options for the other color (see Fig. 2). After the first two steps, we represent the remaining red (blue) regions as vertices in \(G_r\) (\(G_b\)). Edges in \(G_r\) and \(G_b\) represent connection options through purple regions; intersections indicate a choice to connect either blue or red regions through (part of) a purple region. The gadget for purple regions with many adjacent red and blue regions also requires some additional vertices in these graphs. We prove that these graphs admit a simple characterization of 2-colored grids that admit a painting, as captured in the theorem below.

Theorem 1

A 2-colored grid \(\varGamma \) admits a painting if and only if the corresponding graphs \(G_r\) and \(G_b\) are each other’s exact duals: there is exactly one blue vertex in every red face and there is exactly one red vertex in every blue face.

For explanatory reasons we start with the simplest case: purple regions with at most four neighbors and without holes (Sect. 3.1). Subsequently, we alleviate the assumption on the number of neighbors (Sect. 3.2) and permit holes in the purple regions, by showing how to perform Step 2 (Sect. 3.3).

3.1 Simple Purple Regions

We assume that Step 1 has been performed and a purple region has no holes and at most four adjacent regions. The adjacent red and blue regions of a purple region P form an ordered cyclic list as they appear along the boundary of P and alternate in color (due to Step 1). Let \(\kappa (P)\) denote the length of this list for P. \(\kappa \) is even due to color alternation, and by assumption here \(\kappa (P) \le 4\). There can be duplicates in this list as the same red or blue region can touch P multiple times.

Fig. 2.
figure 2

Safe connections between adjacent same-color regions. (Color figure online)

Fig. 3.
figure 3

2-colored grid with 4 regions around each purple region and corresponding graphs \(G_r\) and \(G_b\). (Color figure online)

Every purple region with \(\kappa (P)=2\) can be painted by creating a spanning tree on the centers of the panels of P in one color and connecting it to the corresponding region. The rest of the panels is colored in the other color. We assume these are handled; what remains is to deal with the regions with \(\kappa (P) = 4\).

For a purple region P with \(\kappa (P) = 4\), we create a red edge in \(G_r\) and a blue edge in \(G_b\) that intersect: the red edge connects the red vertices corresponding to the adjacent red regions; the blue edge connects the corresponding blue vertices. There may be multiple edges between two vertices (see Fig. 3). If the same red or blue region touches the purple region twice, the edge is a self-loop. Every red or blue edge intersects exactly one blue or red edge respectively, and \(G_r\) and \(G_b\) are plane by construction. Using the following lemma we prove the exact characterization of graphs \(G_r\) and \(G_b\) of a 2-colored grid \(\varGamma \) that admits a painting.

Lemma 1

([9, 20]). Let G be a plane graph, \(G^*\) its dual and T a spanning tree of G. Then \(T^* = \{ e^* \; | \; e \not \in T \}\) is a spanning tree of \(G^*\).

Lemma 2

A 2-colored grid \(\varGamma \) in which each purple region P has no holes and \(\kappa (P)\le 4\), admits a painting if and only if the corresponding graphs \(G_r\) and \(G_b\) are each other’s exact duals.

Proof

(sketch). We prove that if \(\varGamma \) admits a painting then graphs \(G_r\) and \(G_b\) are each other’s duals using a counting argument. We count the number of edges needed to connect all red and blue regions, and use Euler’s formula to show the number of red faces must be equal to the number of blue vertices, and vice versa. The other direction follows from Lemma 1. Having two dual spanning trees (e.g., Fig. 3), simply draw the two spanning trees and for any cell not yet having a blue (red) piece add a crossing-free connection to the blue (red) polygon.    \(\square \)

3.2 Spiderweb Gadgets

Let us now extend the result in the previous section, by showing how to include purple regions with more than four adjacent regions. For every purple region P with \(\kappa (P) > 4\) we construct a spiderweb gadget and insert it into the graphs \(G_r\) and \(G_b\), such that an argument similar to Lemma 2 can be applied.

A spiderweb gadget W of P with \(\kappa (P)/2 = k\) red and k blue alternating adjacent regions consists of \(\lfloor k/2\rfloor + 1\) levels, labeled 0 (outermost) to \(\lfloor k/2\rfloor \) (innermost), see Fig. 4. Each level, except 0 and \(\lfloor k/2\rfloor \), is a cycle of k vertices. The level 0 has k (blue) vertices without any edges between them, and the innermost level \(\lfloor k/2\rfloor \) consists of only a single vertex. The vertices of even levels are blue and labeled with even numbers from 0 to \(2k-2\) clockwise. The vertices of odd levels are red and labeled with odd numbers 1 to \(2k-1\) clockwise.

Each vertex of level \(\ell \) with \(2 \le \ell < \lfloor k/2 \rfloor \) is connected to the vertex with the same label on level \(\ell -2\). The single vertex of level \(\lfloor k/2\rfloor \) is connected to all the vertices of level \(\lfloor k/2\rfloor -2\). This gives us 2k paths starting from levels 0 and 1 to the two innermost levels. We call these paths spokes, and refer to them by the label of the corresponding vertices. We embed the two resulting connected components in such a way that they are each other’s dual, by making sure that we get a proper clockwise numbering on the vertices of the two outermost levels (see Fig. 4). The vertices on levels 0 and 1 represent respectively the blue and red regions around the purple region P and respect the adjacency order around P.

If a blue (or red) region touches P multiple times, then the corresponding vertices on level 0 (or 1) map to the same region and are in fact one and the same vertex in \(G_b\) (or \(G_r\)). All edges connected to this vertex are consistent with the topology of the nested neighboring regions of P; they intersect the same edges as they would when they were represented by multiple vertices.

To prove that all possible connections in P, which can occur in a painting \(\varPi \), can be replicated in a spiderweb gadget W, we define bridging paths: let u and v be two vertices on level 0 in W that represent two blue regions that are connected by a painting \(\varPi \) through P. Assume that the clockwise distance from u to v is not greater than k, that is, if u has label x then v has label \((x+2i)\mod 2k\) for some \(1 \le i \le \lfloor k/2\rfloor \). To connect u and v with a bridging path, we start from u, go to level \(2\lfloor (i+1)/2 \rfloor \) along the spoke x, take a shortest path within the level \(2\lfloor (i+1)/2 \rfloor \) from the vertex with label x to the vertex with label \((x+2i)\mod 2k\), and move along the spoke \((x+2i)\mod 2k\) to vertex v. If there are two possible shortest paths, we take the clockwise path.

The same kind of path can be constructed for a pair of red vertices, but starting from level 1, going to level \(2\lfloor i/2 \rfloor +1\), and moving back to level 1. We now show that connecting different blue and red regions using bridging paths within the spiderweb gadgets results in blue trees and red trees, such that no pair of a blue and a red edge intersect (see Fig. 5 for an example).

By performing a case analysis on the possible red and blue pairs of adjacent regions to be connected, we can prove that the following lemma holds.

Lemma 3

Consider a painting \(\varPi \) in which two blue and two red regions, adjacent to a purple region P, are connected through P. The corresponding vertices in the spiderweb gadget W of P can be connected by non-intersecting bridging paths.

With spiderweb gadgets and the above lemma, we now strengthen Lemma 2 to the following lemma, without a condition on \(\kappa \), and prove it in a similar way.

Fig. 4.
figure 4

Spiderweb gadget for \(k=6\): three blue levels with indices 0, 2, 4, and two red levels with indices 1, 3. (Color figure online)

Fig. 5.
figure 5

Topology of the connections in a purple region and the corresponding bridging paths through a spiderweb gadget. (Color figure online)

Lemma 4

A 2-colored grid \(\varGamma \) in which each purple region has no holes admits a painting if and only if the corresponding \(G_r\) and \(G_b\) are each other’s exact duals.

3.3 Purple Regions with Holes

We may also have purple regions with holes (see Fig. 6). We show that the number of holes can be reduced without affecting the solvability. For simplicity of explanation we assume a region with a single hole (an annulus); regions with more holes can be reduced by considering only connections to the outer boundary.

Let P be a purple annulus. Any painting subdivides P into a number of colored simple components. Each component of color c connects one or more regions of color c on the boundary of P. The existence of a painting is defined only by the connectivity structure of these components. The connectivity of a component can be represented (transitively) using a set of non-intersecting simple paths (connections) each connecting two regions on the boundary. Let a cross-annulus connection \(\gamma _x\) be a connection between a region \(x_{in}\) on the inside of the annulus and a region \(x_{out}\) on the outside of the annulus. A (connectivity) structure is a maximal set of (pairwise non-intersecting) connections in P that can be extended to a valid painting. Let \(C_S\) be the set of cross-annulus connections in a given structure S. We assume the annulus is not degenerate, so red and blue regions exist both inside and outside the annulus.

Lemma 5

If a structure S exists with two adjacent cross-annulus connections \(\gamma _x\) and \(\gamma _y\) of the same color, possibly separated by non-crossing connections, then there also exists a structure \(S'\) where \(C_{S'}=C_S\setminus \{\gamma _y\}\).

Fig. 6.
figure 6

An annulus-type purple region with adjacent blue and red regions, both inside and outside. (Color figure online)

Fig. 7.
figure 7

By adding edges \((v_{in},y_{in})\) and \((u_{out},x_{out})\) we reconnect the disconnected subpolygons formed be removing cross-annulus connections \(\gamma _v\) and \(\gamma _x\). (Color figure online)

Lemma 6

If there exists a structure S with \(|C_S|>3\) and all cross-annulus connections are alternating in color, then there also exists a structure \(S'\) with \(|C_S|-2\) cross-annulus connections.

Proof

Let \(\gamma _u\), \(\gamma _v\), \(\gamma _x\), and \(\gamma _y\) be four consecutive cross-annulus connections. W.l.o.g., assume \(\gamma _u\) and \(\gamma _x\) are red and \(\gamma _v\) and \(\gamma _y\) are blue. We remove \(\gamma _v\) and \(\gamma _x\) from the structure separating both the red and blue into two components. For both colors one component is still connected to the remaining cross-annulus connection \(\gamma _u\), respectively \(\gamma _y\). The disconnected components cannot both be on the outside (inside) of the annulus. If so, the connection \(\gamma _u\) to \(\gamma _x\) must be connected through \(x_{in}\), and \(\gamma _v\) to \(\gamma _y\) through \(v_{in}\). However, as there is no cross-annulus connection between \(\gamma _u\) and \(\gamma _y\), any connection from \(\gamma _u\) to \(x_{in}\) separates \(\gamma _y\) and \(v_{in}\). Hence, both connections cannot exist at the same time. The red and blue disconnected components are thus on different sides of the annulus and we connect them to \(\gamma _u\) respectively \(\gamma _y\) without mutually interfering (see Fig. 7).    \(\square \)

Corollary 1

If a structure exists, then a structure also exists that has exactly one red and one blue connection across each annulus.

Lemma 7

If a structure exists, then there also exists a structure with exactly one red and one blue cross-annulus connection starting from any two regions on the inner annulus and connecting to any two regions on the outer annulus.

Proof

Let an interval be a maximal arc of the same color on the boundary. By Corollary 1 we know there exists a structure with exactly one red and one blue connection across the annulus. Let \(\gamma _x\) be the blue cross-annulus connection and \(\gamma _y\) the red cross-annulus connection. We show that each of the endpoints of the cross-annulus connection can freely be moved. W.l.o.g., assume that \(\gamma _x\) is not counter-clockwise adjacent to \(\gamma _y\) on the outside of the annulus. Let \(k_{out}\), \(l_{out}\), and \(m_{out}\) be three intervals in clockwise order on the outer boundary of the annulus. We say a clockwise connection through the annulus from \(k_{out}\) to \(m_{out}\) covers \(l_{out}\).

Let \(b_{out}\) be the blue interval that is counter-clockwise adjacent to \(y_{out}\) and \(r_{out}\) the red interval that is counter-clockwise adjacent to \(b_{out}\). Interval \(b_{out}\) may have several incoming blue connections that cover \(r_{out}\) (see Fig. 8(a)). We can rewire the blue connections inside the annulus to connect the blue intervals in sorted order around the annulus, resulting in only one blue connection \(\gamma _b\) that covers \(r_{out}\). Similarly we can also rewire the red connections covering \(r_{out}\), and ending at \(y_{out}\), to ensure only one red connection \(\gamma _r\) covers \(r_{out}\).

Fig. 8.
figure 8

(a) Initial configuration with several connections covering \(r_{out}\). (b) Rerouting the blue connections, introducing \(\gamma _z\), and rerouting the intersecting red connection leaves only one intersecting (blue) connection. (c) As the blue disconnected component cannot be covered by the new red connection, we can always connect it back to \(\gamma _x\). (Color figure online)

Remove \(\gamma _y\) and insert a new red cross-annulus connection \(\gamma _z = (y_{in},r_{out})\). The connection \(\gamma _z\) can only intersect \(\gamma _r\) and \(\gamma _b\). Removing \(\gamma _r\) results in two red components, one of which contains \(\gamma _z\). Assume w.l.o.g. that \(y_{out}\) is in the same connected component as \(\gamma _z\). As \(\gamma _r\) intersected \(\gamma _z\), the disconnected component can be connected to \(\gamma _z\) while only intersecting \(\gamma _b\) (see Fig. 8(b)).

Removing \(\gamma _b\) results in two blue components, one of which contains \(\gamma _x\). We prove that \(b_{out}\) must be part of the blue component not containing \(\gamma _x\). Assume to the contrary that \(b_{out}\) is still connected to \(\gamma _x\). Interval \(r_{out}\) must be connected to \(y_{out}\) outside of the annulus as there was only one red cross-annulus connection and \(\gamma _b\) blocked any connection through the inside of the annulus. Similarly, interval \(b_{out}\) must have been connected through the outside of the annulus, as it is separated from any other region inside the annulus by \(\gamma _y\) and \(\gamma _z\). However, they cannot both be connected through the outside of the annulus, as the connection \(r_{out}\) to \(y_{out}\) separates \(b_{out}\) and \(x_{out}\) on the outside of the annulus. Contradiction.

Therefore, we can safely reconnect the disconnected blue component through the annulus to \(\gamma _x\) (see Fig. 8(c)). Repeatedly moving the end-point of one of the cross-annulus connections allows the creation of any configuration of the two red and blue cross-annulus connections without invalidating the structure.    \(\square \)

Lemma 7 implies that we can cut the annulus open to reduce the number of holes of a purple region by one without changing the solvability of the problem. Together with Lemma 4, this then implies Theorem 1.

Fig. 9.
figure 9

Panels with complexity 3 and 5 respectively. (Color figure online)

4 Optimizing Panels

As shown, not all colored grids admit a painting. Here we investigate the design of the panels themselves, assuming that some painting is possible. To this end, we define the complexity of a panel as the number of pieces of maximal red and blue areas in the panel, see Fig. 9. The complexity of a painting is the maximal complexity of any of its panels. A t-panel (t-painting) has complexity t.

Assuming some painting exists, we prove in this section that a 5-painting exists in general and that even a 2-painting exists if there are no white cells.

4.1 Ensuring a 5-Painting

We prove here that a 5-painting can always be realized. To this end, we show that a valid painting for a colored grid can be redrawn to include no more than three colored intervals along each side of all panels.

Fig. 10.
figure 10

Reducing the number of intervals along a side of panel \(\pi \), where there are at least four. (b) The two middle directions cannot be the same, as we cannot connect them with nonintersecting paths. (c) Shortcutting inside \(\pi \) reduces the number of intervals while maintaining a painting. (Color figure online)

Fig. 11.
figure 11

A panel with six pieces can always be reduced to have five, using either dotted line. (Color figure online)

Lemma 8

If a 2-colored grid admits a painting, then it admits a painting where each panel \(\pi \) has at most 3 intervals of alternating red and blue along each side.

Proof

(sketch). Assume that a panel \(\pi \) has at least 4 intervals of alternating red and blue on the left-side of \(\pi \). As the painting is valid, both blue (/red) intervals are connected in the painting. For each interval we identify whether the path exiting or entering \(\pi \) connects to the other interval of the same color (see Fig. 10(a)). The red and blue path cannot leave or exit the border of \(\pi \) in the same direction for the middle two intervals (see Fig. 10(b)). To reduce the number of intervals, we recolor the interval by shortcutting both the blue and the red piece inside \(\pi \) (see Fig. 10(c)).    \(\square \)

Theorem 2

If a partially 2-colored grid admits a painting, then it admits a 5-painting.

Proof

By Lemma 8 there are at most three alternatingly colored intervals along each side of \(\pi \). If a red and blue interval meet in a corner, we extend one in \(\pi \) around the corner to get four intervals and use Lemma 8 to reduce it back to at most three. If we have more than five pieces, a piece that has only one interval in \(\pi \) can be removed while maintaining a painting. Each remaining piece connects at least two intervals: with k intervals, the number of pieces is at most \(\lfloor k/2 \rfloor \). A 6-panel thus requires 12 intervals: four equal-color (red) corners and a middle interval (blue) along each side. This enforces two pieces between the blue intervals, and one in each corner. However, we can now reduce the number of pieces to five, connecting either two blue pieces or two red corners (Fig. 11).    \(\square \)

This bound is tight as a 5-panel may be required when the grid includes white cells (Fig. 12(a)). A 5-panel with at least two pieces of each color is never required—though such a 4-panel may be necessary (Fig. 12(b)). The above proof implies that there is only one option to create such a 5-panel: it has only two ways to connect the two blue pieces; both can be simplified to a 4-panel (Fig. 13).

Fig. 12.
figure 12

Examples requiring complex panels. (a) A colored grid requiring a 5-panel. (b) A colored grid requiring a 4-panel with two pieces of both colors in the same cell. (Color figure online)

Fig. 13.
figure 13

There are two configurations for a 5-panel where both colors have at least two pieces. Both possible configuration can be simplified to a 4-panel. (Color figure online)

4.2 Ensuring a 2-Painting

We show that a fully 2-colored grid (rectangular and without white cells) even admits a 2-painting, provided it admits any painting. As an intermediate step, we first prove that a painting exists that uses only one blue piece in any panel.

Lemma 9

If a fully 2-colored grid admits a painting, then it admits a painting in which each panel has at most one blue piece.

Proof

(sketch). Since the grid admits a painting, we show how to modify the painting of each purple region P to ensure that the lemma holds. We first create a blue spanning forest in the panels of P that connects the panel-centers of adjacent panels. This ensures that each panel has exactly one blue piece inside, but may result in a disconnected blue polygon. However, since we know that a painting exists and the current solution maps to some forest in \(G_b\), Lemma 1 implies that its dual \(G_r\) has a cycle around some tree in the forest. Hence, we can add connections between unconnected subpolygons to create a single blue polygon again, without disconnecting the red polygon.    \(\square \)

The above construction relies on the alternation of the blue and red intervals along the boundary of P. As there are no white cells we can guarantee this alternating pattern. Indeed, the higher complexity with white cells is caused by long connections along a purple region’s boundary that are needed to achieve this alternating pattern for a partially colored grid (e.g., Fig. 12).

Fig. 14.
figure 14

Reducing panel complexity when there are two red corners along the same panel side. (a) The corners are connected via adjacent (or the same) sides of the panel: connect \(r_1\) and \(r_2\), and recolor \(r_3\) to blue. (b) The corners are connected via opposite sides: recolor \(r_1\) to blue and connect \(r_3\) and \(r_4\) as well as \(b_1\) and \(b_2\). (Color figure online)

Theorem 3

If a fully 2-colored grid admits a painting, then it admits a 2-painting.

Proof

(sketch). Since the fully 2-colored grid admits a painting, Lemma 9 implies that there is a painting \(\varPi \) where the panel for every purple cell contains only a single blue piece. For any purple cell with more than one red piece, we remove red pieces that only connect to one neighboring panel and recolor red corners to blue if the other three cells incident to that corner have a red corner as well. Now, the pattern of the panel matches one of the following four cases.

  1. 1.

    There are two red corners \(r_1\) and \(r_2\) on the same side of the panel. The connecting path exits the current panel via the same side and enters either on the same or adjacent side (see Fig. 14(a)).

  2. 2.

    There are two red corners \(r_1\) and \(r_2\) on the same side of the panel. The connecting path exits the panel via opposite sides of the panel (see Fig. 14(b)). The blue piece connects only downwards in the panel below.

  3. 3.

    There are two red corners \(r_1\) and \(r_2\) that do not share a common side of the panel. In this case the other corners are blue, otherwise one of the two previous cases applies (see Fig. 15(a)). Furthermore, either \(p_1\) or \(p_2\) is blue.

  4. 4.

    There are two red corners \(r_1\) and \(r_2\) that do not share a common side of the panel (see Fig. 15(b)). Furthermore, both \(p_1\) and \(p_2\) are red.

Fig. 15.
figure 15

Two diagonally positioned red corners. The complexity of the panel can be reduced by introducing a red L-shape that connects all the red. (a) Reducing complexity if either \(p_1\) or \(p_2\) was blue. (b) Reducing complexity if both \(p_1\) and \(p_2\) were red. (Color figure online)

We design a reduction rule for each case, as sketched in Figs. 14 and 15. Repeated application of the reduction rules, interlaced with the reduction of the number of red pieces in a panel, results in a 2-painting.    \(\square \)

5 Conclusion

We took the first steps towards investigating a disjoint-polygons representation for visualizing set memberships (hypergraphs). We investigated the 2-color version in which each element is positioned as a cell in a (unit-)grid. We showed how to test whether a disjoint-polygons representation is possible for a given 2-colored grid. Moreover, we proved that if such a representation is possible, then we can also bound the complexity of the corresponding “panels” (the coloring of a single cell). Each panel requires at most five colored pieces, and even only two pieces are sufficient when no white cells are present in the grid.

There are myriad options for further exploration. As not all grids admit a painting, we could study minimizing the number of polygons of the same color. We have not touched upon variants with more colors: does our approach readily generalize? However, considering the restrictions already in the studied 2-color variant, it seems likely that many practical instances do not admit a painting. If we allow rearranging elements, the 2-color variant becomes trivial, but is particularly interesting for multiple colors. Finally, we may consider the situation where some cells have no assigned set of colors but may be painted using any subset of the colors. Given enough such cells, the disjoint-polygons encoding can then represent more than Zykov-planar hypergraphs but cannot represent all planar supports.