1 Introduction

Asinowski et al. [3] introduced the class of vertex intersection graphs of paths on a grid, referred to as VPG graphs. An undirected graph \(G=(V,E)\) is called a VPG graph if one can associate a path on a grid with each vertex such that two vertices are adjacent if and only if the corresponding paths intersect on at least one grid-point. It is not difficult to see that the class of VPG graphs coincides with the class of string graphs, i.e. intersection graphs of curves in the plane (see [3]).

A natural restriction which was forthwith considered consists in limiting the number of bends (i.e. \(90^\circ \) turns at a grid-point) that the paths may have: an undirected graph \(G=(V,E)\) is a \(B_k\)-VPG graph, for some integer \(k\ge 0\), if one can associate a path on a grid having at most k bends with each vertex such that two vertices are adjacent if and only if the corresponding paths intersect on at least one grid-point. Since their introduction, \(B_k\)-VPG have been extensively studied (see [2, 3, 5, 7,8,9, 14, 15, 18,19,20]).

A notion closely related to intersection graphs is that of contact graphs. Such graphs can be seen as a special type of intersection graphs of geometrical objects in which these objects are not allowed to have common interior points but only to touch each other. Contact graphs of various types of objects have been studied in the literature (see, e.g., [1, 10, 11, 21,22,23]). In this paper, we consider Contact graphs of Paths on a Grid (CPG graphs for short) which are defined as follows. A graph G is a CPG graph if the vertices of G can be represented by a family of interiorly disjoint paths on a grid, two vertices being adjacent in G if and only if the corresponding paths touch, i.e. share a grid-point which is an endpoint of at least one of the two paths (see Fig. 1). Note that this class is hereditary, i.e. closed under vertex deletion. Similarly to VPG, a \(B_k\)-CPG graph is a CPG graph admitting a representation in which each path has at most k bends. Clearly, any \(B_k\)-CPG graph is also a \(B_k\)-VPG graph.

Fig. 1.
figure 1

Examples of types of contact between two paths (the endpoints of a path are marked by an arrow).

Aerts and Felsner [1] considered a similar family of graphs, namely those admitting a Vertex Contact representation of Paths on a Grid (VCPG for short). The vertices of such graphs can be represented by a family of interiorly disjoint paths on a grid, but the adjacencies are defined slightly differently: two vertices are adjacent if and only if the endpoint of one of the corresponding paths touches an interior point of the other corresponding path (observe that this is equivalent to adding the constraint forbidding two paths from having a common endpoint, i.e. contacts as in Fig. 1a on the right). This class has been considered by other authors as well (see [6, 7, 14, 19, 24]).

It is not difficult to see that graphs admitting a VCPG are planar (see [1]) and it immediately follows from the definition that those graphs are CPG graphs. This containment is in fact strict even when restricted to planar CPG graphs, as there exist, in addition to nonplanar CPG graphs, planar graphs which are CPG but do not admit a VCPG.

To the best of our knowledge, the class of CPG graphs has never been studied in itself and our present intention is to provide some structural properties (see Sect. 3). By considering a specific weight function on the vertices, we provide upper bounds on the number of edges in CPG graphs as well as on the clique number and the chromatic number (see Sect. 3). In particular, we show that \(B_0\)-CPG graphs are 4-colorable and that 3-colorability restricted to \(B_0\)-CPG is \(\mathsf {NP}\)-complete (see Sect. 5). We further prove that recognizing \(B_0\)-CPG graphs is \(\mathsf {NP}\)-complete. Additionally, we show that the classes of CPG graphs and planar graphs are incomparable (see Sect. 4).

2 Preliminaries

Throughout this paper, all considered graphs are undirected, finite and simple. For any graph theoretical notion not defined here, we refer the reader to [13].

Let \(G=(V,E)\) be a graph with vertex set V and edge set E. The degree of a vertex \(v\in V\), denoted by d(v), is the number of neighbors of v in G. A graph G is k-regular if the degree of every vertex in G is \(k\ge 0\). A clique (resp. stable set) in G is a set of pairwise adjacent (resp. nonadjacent) vertices. The graph obtained from G by deleting a vertex \(v\in V\) is denoted by \(G - v\). For a given graph H, G is H-free if it contains no induced subgraph isomorphic to H.

As usual, \(K_n\) (resp. \(C_n\)) denotes the complete graph (resp. chordless cycle) on n vertices and \(K_{m,n}\) denotes the complete bipartite graph with bipartition \((V_1,V_2)\) such that \(|V_1| = m\) and \(|V_2| = n\). Given a graph G, the line graph of G, denoted by L(G), is the graph such that each vertex \(v_e\) in L(G) corresponds to an edge e in G and two vertices are adjacent in L(G) if and only if their corresponding edges in G have a common endvertex.

A graph G is planar if it can be drawn in the plane without crossing edges; such a drawing is then called a planar embedding of G. A planar embedding divides the plane into several regions referred to as faces. A planar graph is maximally planar if adding any edge renders it nonplanar. A maximally planar graph has exactly \(2n-4\) faces, where n is the number of vertices in the graph. A graph H is a minor of a graph G, if H can be obtained from G by deleting edges and vertices and by contracting edges. It is well-known that a graph is planar if and only if it does not contain \(K_5\) or \(K_{3,3}\) as a minor [13].

A coloring of a graph G is a mapping \(\mathbf {c}\) associating with every vertex u an integer \(\mathbf {c}(u)\), called a color, such that \(\mathbf {c}(v)\ne \mathbf {c}(u)\) for every edge uv. If at most k distinct colors are used, \(\mathbf {c}\) is called a k-coloring. The smallest integer k such that G admits a k-coloring is called the chromatic number of G, denoted by \(\chi (G)\).

Consider a rectangular grid \(\mathcal {G}\) where the horizontal lines are referred to as rows and the vertical lines as columns. The grid-point lying on row x and column y is denoted by (xy). An interior point of a path P on \(\mathcal {G}\) is a point belonging to P and different from its endpoints; the interior of P is the set of all its interior points. A graph \(G=(V,E)\) is CPG if there exists a collection \(\mathcal {P}\) of interiorly disjoint paths on a grid \(\mathcal {G}\) such that \(\mathcal {P}\) is in one-to-one correspondence with V and two vertices are adjacent in G if and only if the corresponding paths touch; if every path in \(\mathcal {P}\) has at most k bends, G is \(B_k\)-CPG. The pair \(\mathcal {R} = (\mathcal {G},\mathcal {P})\) is a CPG representation of G, and more specifically a k-bend CPG representation if every path in \(\mathcal {P}\) has at most k bends. In the following, the path representing some vertex u in a CPG representation \(\mathcal {R}\) of a graph G is denoted by \(P_u^{\mathcal {R}}\), or simply \(P_u\) if it is clear from the context.

Let \(G=(V,E)\) be a CPG graph and \(\mathcal {R} = (\mathcal {G},\mathcal {P})\) be a CPG representation of G. A grid-point p is of type I if it corresponds to an endpoint of four paths in \(\mathcal {P}\) (see Fig. 2a), and of type II if it corresponds to an endpoint of two paths in \(\mathcal {P}\) and an interior point of a third path in \(\mathcal {P}\) (see Fig. 2b).

Fig. 2.
figure 2

Two types of grid-points.

For any grid-point p, we denote by \(\tau (p)\) the number of edges in the subgraph induced by the vertices whose corresponding paths contain or have p as an endpoint. Note that this subgraph is a clique and so \(\tau (p)=\left( {\begin{array}{c}j\\ 2\end{array}}\right) \) if j paths touch at grid-point p.

For any path P, we denote by \(\mathring{P}\) (resp. \(\partial (P)\)) the interior (resp. endpoints) of P. For a vertex \(u \in V\), we define the weight of u with respect to \(\mathcal {R}\), denoted by \(w_u^{\mathcal {R}}\) or simply \(w_u\) if it is clear from the context, as follows. Let \(q_u^i\) (\(i=1,2\)) be the endpoints of the corresponding path \(P_u\) in \(\mathcal {P}\) and consider, for \(i=1,2\),

$$\begin{aligned} w_u^i = |\{P \in \mathcal {P} ~|~ q_u^i \in \mathring{P}\}| + \frac{1}{2} \cdot |\{P \in \mathcal {P} ~|~ P \ne P_u \text { and } q_u^i \in \partial (P)\}|. \end{aligned}$$

Then \(w_u = w_u^1 + w_u^2\).

Observation 1

Let \(G=(V,E)\) be a CPG graph and \(\mathcal {R} = (\mathcal {G},\mathcal {P})\) be a CPG representation of G. For any vertex \(u \in V\) and \(i=1,2\), \(w_u^i \le \frac{3}{2}\) where equality holds if and only if \(q_u^i\) is a grid-point of type I or II.

Indeed, the contribution of \(q_u^i\) to \(w_u^i\) is maximal if all four grid-edges containing \(q_u^i\) are used by paths of \(\mathcal {P}\), which may only happen when \(q_u^i\) is a grid-point of type I or II.

Remark

In fact, we have \(w_u^i \in \{0,\frac{1}{2},1,\frac{3}{2}\}\) for any vertex \(u \in V\) and \(i=1,2\).

Observation 2

Let \(G=(V,E)\) be a CPG graph and \(\mathcal {R} = (\mathcal {G},\mathcal {P})\) be a CPG representation of G. Then

$$\begin{aligned} |E| \le \sum \limits _{u \in V} w_u, \end{aligned}$$

where equality holds if and only if all paths of \(\mathcal {P}\) pairwise touch at most once.

Indeed, if \(uv \in E\), we may assume that either an endpoint of \(P_u\) touches the interior of \(P_v\), or \(P_u\) and \(P_v\) have a common endpoint. In the first case, the edge uv is fully accounted for in the weight of u, and in the second case, the edge uv is accounted for in both \(w_u\) and \(w_v\) by one half. The characterization of equality then easily follows.

3 Structural Properties of CPG Graphs

In this section, we investigate CPG graphs from a structural point of view and present some useful properties which we will further exploit.

Lemma 1

A CPG graph is either 6-regular or has a vertex of degree at most 5.

Proof

If \(G=(V,E)\) is a CPG graph and \(\mathcal {R}\) is a CPG representation of G, by combining Observations 1 and 2, we obtain

$$ \sum \limits _{u \in V} d(u) = 2|E| \le 2\sum \limits _{u \in V} w_u \le 2\sum \limits _{u \in V} \bigg ( \frac{3}{2} + \frac{3}{2}\bigg ) = 6|V|. $$

   \(\square \)

Remark

We can show that there exists an infinite family of 6-regular CPG graphs. Due to lack of space, this proof is here omitted but can be found in the full version [12].

For \(B_1\)-CPG graphs, we can strengthen Lemma 1 as follows.

Proposition 1

Every \(B_1\)-CPG graph has a vertex of degree at most 5.

Proof

Let \(G=(V,E)\) be a \(B_1\)-CPG graph and \(\mathcal {R}\) be a 1-bend CPG representation of G. Denote by p the upper-most endpoint of a path among the left-most endpoints in \(\mathcal {R}\), and by \(P_x\) (with \(x \in V\)) an arbitrary path having p as an endpoint. Since \(\mathcal {R}\) is a 1-bend CPG representation, no path uses the grid-edge on the left of p, for otherwise p would not be a left-most endpoint. Therefore, p contributes to the weight of x with respect to \(\mathcal {R}\) by at most 1 and, by Observations 1 and 2, we have

$$\begin{aligned} \sum \limits _{u \in V} d(u) = 2|E| \le 2 (w_x + \sum \limits _{u \ne x} w_u) \le 6|V| - 1, \end{aligned}$$

which implies the existence of a vertex of degree at most 5.    \(\square \)

A natural question that arises when considering CPG graphs is whether they may contain large cliques. It immediately follows from Observation 2 that CPG graphs cannot contain \(K_n\), for \(n\ge 8\). This can be further improved as shown in the next result.

Theorem 1

CPG graphs are \(K_7\)-free.

Proof

Since the class of CPG graphs is hereditary, it is sufficient to show that \(K_7\) is not a CPG graph. Suppose, to the contrary, that \(K_7\) is a CPG graph and consider a CPG representation \(\mathcal {R} = (\mathcal {G},\mathcal {P})\) of \(K_7\). Observe first that the weight of every vertex with respect to \(\mathcal {R}\) must be exactly \(2 \cdot 3/2\), as otherwise by Observation 1, we would have \(\sum _{u\in V} w_u < 3|V|=21=|E|\) which contradicts Observation 2. This implies in particular that every grid-point corresponding to an endpoint of a path is either of type I or II. Furthermore, any two paths must touch at most once, for otherwise by Observation 2, \(|E| < \sum _{u\in V} w_u = 3|V|=|E|\). Hence, if we denote by \(P_I\) (resp. \(P_{II}\)) the set of grid-points of type I (resp. type II), then since \(\tau (p) = 6\) for all \(p \in P_I\) and \(\tau (p) = 3\) for all \(p \in P_{II}\), we have that \(6|P_I| + 3|P_{II}| = 21\), which implies \(|P_{II}| \ne 0\). Suppose that there exists a path \(P_u\) having one endpoint corresponding to a grid-point of type I and the other corresponding to a grid-point of type II. Since the corresponding vertex u has degree 6, \(P_u\) must then properly contain an endpoint of another path which, as first observed, necessarily corresponds to a grid-point of type II. But vertex u would then have degree \(3+2+2\) as no two paths touch more than once, a contradiction. Hence, every path has both its endpoints of the same type. But then, \(|P_I| = 0\); indeed, if there exists a path having both its endpoints of type I, since no two paths touch more than once, this implies that every path has both its endpoints of type I, i.e. \(|P_{II}| =0\), a contradiction. Now, if we consider each grid-point of type II as a vertex and connect any two such vertices when the corresponding grid-points belong to a same path, then we obtain a planar embedding of a 4-regular graph on 7 vertices. But this contradicts the fact that every 4-regular graph on 7 vertices contains \(K_{3,3}\) as a minor (a proof of this result can be found in the full version [12]).    \(\square \)

However, CPG graphs may contain cliques on 6 vertices as shown in Proposition 2. Due to lack of space, its proof is omitted here and can be found in the full version [12].

Proposition 2

\(K_6\) is in \(B_2\)-CPG \(\backslash B_1\)-CPG.

We conclude this section with a complexity result pointing towards the fact that there may not be a polynomial characterization of \(B_0\)-CPG graphs. Let us first introduce rectilinear planar graphs: a graph G is rectilinear planar if it admits a rectilinear planar drawing, i.e. a drawing mapping each edge to a horizontal or vertical segment.

Theorem 2

Recognition is \(\mathsf {NP}\)-complete for \(B_0\)-CPG graphs.

Proof

We show that a graph G is rectilinear planar if and only if its line graph L(G) is \(B_0\)-CPG. As Recognition for rectilinear planar graphs was shown to be \(\mathsf {NP}\)-complete in [17], this concludes the proof. Suppose G is a rectilinear planar graph and let \(\mathcal {D}\) be the collection of horizontal and vertical segments in a rectilinear planar drawing of G. It is not difficult to see that the contact graph of \(\mathcal {D}\) is isomorphic to L(G). Conversely, assume that L(G) is a \(B_0\)-CPG graph and consider a 0-bend CPG representation \(\mathcal {R} = (\mathcal {G},\mathcal {P})\) of L(G). Since L(G) is \(K_{1,3}\)-free [4], every path in \(\mathcal {P}\) has at most two contact points. Thus, by eventually shortening paths, we may assume that contacts only happen at endpoints of paths. Therefore, \(\mathcal {R}\) induces a rectilinear planar drawing of G, where each vertex corresponds to a contact point in \(\mathcal {R}\) and each edge is mapped to its corresponding path in \(\mathcal {P}\).    \(\square \)

4 Planar CPG Graphs

In this section, we focus on planar graphs and their relation with CPG graphs. In particular, we show that not every planar graph is CPG and not all CPG graphs are planar.Footnote 1

Lemma 2

If G is a CPG graph for which there exists a CPG representation containing no grid-point of type I or II.a, then G is planar. In particular, if G is a triangle-free CPG graph, then G is planar.

Proof

Let \(G=(V,E)\) be a CPG graph for which there exists a CPG representation \(\mathcal {R}\) containing no grid-point of type I or II.a. By considering each path of \(\mathcal {R}\) as a curve in the plane, it follows that G is a curve contact graph having a representation (namely \(\mathcal {R}\)) in which any point in the plane belongs to at most three curves. Furthermore, whenever a point in the plane belongs to the interior of a curve \(\mathcal {C}\) and corresponds to an endpoint of two other curves, then those two curves lie on the same side of \(\mathcal {C}\) (recall that there is no grid-point of type II.a). Hence, it follows from Proposition 2.1 in [21] that G is planar.

If G is a triangle-free CPG graph, then no CPG representation of G contains grid-points of type I or II.a. Hence, G is planar.    \(\square \)

Remark

Since \(K_{3,3}\) is a triangle-free nonplanar graph, it follows from Lemma 2 that \(K_{3,3}\) is not CPG. Therefore, CPG graphs are \(K_{3,3}\)-free. Observe however that for any \(k \ge 0\), \(B_k\)-CPG is not a subclass of planar graphs as there exist \(B_0\)-CPG graphs which are not planar (see Fig. 3).

Fig. 3.
figure 3

A \(B_0\)-CPG graph containing \(K_{3,3}\) as a minor (contract the edge e).

It immediately follows from [7] that all triangle-free planar graphs are \(B_1\)-CPG; hence, we have the following corollary.

Corollary 1

If a graph G is triangle-free, then G is planar if and only if G is \(B_1\)-CPG.

The next result allows us to detect planar graphs that are not CPG.

Lemma 3

Let \(G = (V,E)\) be a planar graph. If G is a CPG graph, then G has at most \(4|V| - 2f + 4\) vertices of degree at most 3, where f denotes the number of faces of G. In particular, if G is maximally planar, then G has at most 12 vertices of degree at most 3.

Proof

Let \(G = (V,E)\) be a planar CPG graph and \(\mathcal {R}=(\mathcal {G},\mathcal {P})\) a CPG representation of G. Denote by U the subset of vertices in G of degree at most 3. If a path \(P_u\), with \(u \in U\), touches every other path in \(\mathcal {P}\) at most once, then, since at least one endpoint of \(P_u\) is then not a grid-point of type I or II, the weight of u with respect to \(\mathcal {R}\) is at most \(3/2 + 1\). Thus, if we assume that this is the case for all paths whose corresponding vertex is in U, we have by Observation 2

$$\begin{aligned} |E| \le \bigg (\frac{3}{2} + 1\bigg ) |U| + 3(|V| - |U|) = 3|V| - \frac{|U|}{2}. \end{aligned}$$

On the other hand, if there exists \(u \in U\) such that \(P_u\) touches some path more than once, then the above inequality still holds as the corresponding edge is already accounted for. Using the fact that \(f = |E| - |V| + 2\) (Euler’s formula), we obtain the desired upper bound. Moreover, if G is maximally planar, then \(f = 2|V| - 4\) and so \(|U| \le 12\).    \(\square \)

Remark

In Fig. 4a, we give an example of a maximally planar graph which is not CPG due to Lemma 3. It is constructed by iteratively adding a vertex in a triangular face, starting from the triangle, so that it has exactly 13 vertices of degree 3. There exist however maximally planar graphs which are CPG (see Fig. 4b). Note that maximally planar graphs do not admit a VCPG [1].

Fig. 4.
figure 4

Two maximally planar graphs.

5 Coloring CPG Graphs

In this section, we provide tight upper bounds on the chromatic number of \(B_k\)-CPG graphs for different values of k and investigate the 3-Colorability problem for CPG graphs. The proof of the following result is an easy exercise left to the reader (see the full version [12]).

Theorem 3

CPG graphs are 6-colorable.

Remark

Since \(K_6\) is \(B_2\)-CPG, this bound is tight for \(B_k\)-CPG graphs with \(k \ge 2\). We leave as an open problem whether this bound is also tight for \(B_1\)-CPG graphs (note that it is at least 5 since \(K_5\) is \(B_1\)-CPG).

Theorem 4

\(B_0\)-CPG graphs are 4-colorable. Moreover, \(K_4\) is a 4-chromatic \(B_0\)-CPG graph.

Proof

Let G be a \(B_0\)-CPG graph and \(\mathcal {R}=(\mathcal {G},\mathcal {P})\) a 0-bend CPG representation of G. Denote by \(\mathcal {L}\) (resp. \(\mathcal {C}\)) the set of rows (resp. columns) of \(\mathcal {G}\) on which lies at least one path of \(\mathcal {P}\). Since the representation contains no bend, if A is a row in \(\mathcal {L}\) (resp. column in \(\mathcal {C}\)), then the set of vertices having their corresponding path on A induces a collection of disjoint paths in G. If \(B \ne A\) is another row in \(\mathcal {L}\) (resp. column in \(\mathcal {C}\)), then no path in A touches a path in B. Hence, it suffices to use two colors to color the vertices having their corresponding path in a row of \(\mathcal {L}\) and two other colors to color the vertices having their corresponding path in a column of \(\mathcal {C}\) to obtain a proper coloring of G.    \(\square \)

It immediately follows from a result in [22] that the 3-colorability problem is \(\mathsf {NP}\)-complete in CPG, even if the graph admits a representation in which each grid-point belongs to at most two paths. We conclude this section by a strengthening of this result.

Theorem 5

3-Colorability is \(\mathsf {NP}\)-complete in \(B_0\)-CPG.

Proof

We exhibit a polynomial reduction from 3-Colorability restricted to planar graphs of maximum degree 4, which was shown to be \(\mathsf {NP}\)-complete in [16].

Let \(G=(V,E)\) be a planar graph of maximum degree 4. It follows from [26] that G admits a grid embedding where each vertex is mapped to a grid-point and each edge is mapped to a grid-path with at most 4 bends, in such a way that all paths are interiorly disjoint (such an embedding can be obtained in linear time). Denote by \(\mathcal {D} = (\mathcal {V}, \mathcal {E})\) such an embedding, where \(\mathcal {V}\) is the set of grid-points in one-to-one correspondence with V and \(\mathcal {E}\) is the set of grid-paths in one-to-one correspondence with E. For any vertex \(u \in V\), we denote by \((x_u,y_u)\) the grid-point in \(\mathcal {V}\) corresponding to u and by \(P_u^N\) (resp. \(P_u^S\)) the path of \(\mathcal {E}\), if any, having \((x_u,y_u)\) as an endpoint and using the grid-edge above (resp. below) \((x_u,y_u)\). For any edge \(e \in E\), we denote by \(P_e\) the path in \(\mathcal {E}\) corresponding to e. We construct from \(\mathcal {D}\) a 0-bend CPG representation \(\mathcal {R}\) in such a way that the corresponding graph \(G'\) is 3-colorable if and only if G is 3-colorable.

Fig. 5.
figure 5

Constructing the path \(P_u\) corresponding to vertex u (in blue). (Color figure online)

Fig. 6.
figure 6

Replacing interior vertical segments by 0-bend paths (in blue). (Color figure online)

By eventually adding rows and columns to the grid, we may assume that the interior of each path P in \(\mathcal {E}\) is surrounded by an empty region, i.e. no path \(P' \ne P\) or grid-point of \(\mathcal {V}\) lies in the interior of this region. In the following, we denote this region by \(\mathcal {R}_P\) (delimited by red dashed lines in every subsequent figure) and assume, without loss of generality, that it is always large enough for the following operations.

We first associate with every vertex \(u \in V\) a vertical path \(P_u\) containing the grid-point \((x_u,y_u)\) as follows. If \(P_u^N\) (resp. \(P_u^S\)) is not defined, the top (resp. lower) endpoint of \(P_u\) is \((x_u,y_u + \varepsilon )\) (resp. \((x_u,y_u - \varepsilon )\)) for a small enough \(\varepsilon \) so that the segment \([(x_u,y_u),(x_u,y_u + \varepsilon )]\) (resp. \([(x_u,y_u),(x_u,y_u - \varepsilon )]\)) touches no path of \(\mathcal {E}\). If \(P_u^N\) has at least one bend, then the top endpoint of \(P_u\) lies at the border of \(\mathcal {R}_{P_u^N}\) on column \(x_u\) (see Fig. 5a). If \(P_u^N\) has no bend, then the top endpoint of \(P_u\) lies at the middle of \(P_u^N\) (see Fig. 5b). Similarly, we define the lower endpoint of \(P_u\) according to \(P_u^S\): if \(P_u^S\) has at least one bend, then the lower endpoint of \(P_u\) lies at the border of \(\mathcal {R}_{P_u^S}\) on column \(x_u\), otherwise it lies at the middle of \(P_u^S\).

For any path P of \(\mathcal {E}\) with at least two bends, an interior vertical segment of P is a vertical segment of P containing none of its endpoints (note that since every path in \(\mathcal {E}\) has at most 4 bends, it may contain at most two interior vertical segments). We next replace every interior segment of P by a slightly longer vertical path touching the border of \(\mathcal {R}_P\) (see Fig. 6).

We finally introduce two gadgets H (see Fig. 7) and \(H'\), where \(H'\) is the subgraph of H induced by \(\{b,c,4,5,6,7,8,9,10\}\), as follows. Denote by \(\mathcal {P}'\) the set of vertical paths introduced so far and by \(V'\) the set of vertices of the contact graph of \(\mathcal {P}'\). Observe that \(V'\) contains a copy of V and that two vertices are adjacent in the contact graph of \(\mathcal {P}'\) if and only if they are both copies of vertices in V and the path P of \(\mathcal {P}\) corresponding to the edge between these two copies is a vertical path with no bend. Now, along each path \(P_{uv}\) of \(\mathcal {P}\) such that the vertical paths \(P_u\) and \(P_v\) of \(\mathcal {P}'\) do not touch, we add gadgets H and \(H'\) as follows. Let \(P_1, \ldots , P_k\) be the vertical paths of \(\mathcal {P}'\) encountered in order when going along \(P_{uv}\) from \((x_u,y_u)\) to \((x_v,y_v)\) and let \(u_j\) be the vertex of \(V'\) corresponding to \(P_j\), for \(1 \le j \le k\). Note that \(P_1\) (resp. \(P_k\)) is the path corresponding to vertex \(u= u_1\) (resp. \(v=u_k\)) and that \(P_j\), for \(2\le j\le k-1\), is a path corresponding to an interior vertical segment of \(P_{uv}\) (this implies in particular that \(k \le 4\)). We add the gadget \(H'\) in between \(u_1\) and \(u_2\) by identifying \(u_1\) with b and \(u_2\) with c. Moreover, for any \(2 \le j \le k-1\), we add the gadget H in between \(u_j\) and \(u_{j+1}\) by identifying \(u_j\) with b and \(u_{j+1}\) with a (see Fig. 8 where \(k=4\) and each box labeled H (resp. \(H'\)) means that gadget H (resp. \(H'\)) has been added by identifying the vertex lying to the left of the box to b and the vertex lying on the right of the box to a (resp. c)).

The resulting graph \(G'\) remains \(B_0\)-CPG. Indeed, we may add 0-bend CPG representations of the gadgets H and \(H'\) inside \(\mathcal {R}_{P_{uv}}\) and at different heights so that they do not touch any other such gadget, as shown in Fig. 9. In the full version [12], we give a local example of the resulting 0-bend CPG representation \(\mathcal {R}\).

We now show that G is 3-colorable if and only if \(G'\) is. To this end, we prove the following.

Claim 1

  • In any 3-coloring \(\mathbf {c}\) of \(H'\), we have \(\mathbf {c}(b) \ne \mathbf {c}(c)\).

  • In any 3-coloring \(\mathbf {c}\) of H, we have \(\mathbf {c}(a) = \mathbf {c}(b)\) and \(\mathbf {c}(b) \ne \mathbf {c}(c)\).

Proof. Let \(\mathbf {c} :\{a,b,c,1,2,3,4,5,6,7,8,9,10\} \rightarrow \{blue,red,green\}\) be a 3-coloring of H and assume without loss of generality that \(\mathbf {c}(b) = blue\). Clearly, at least two vertices among 4, 6 and 8 have the same color. If vertices 4, 6 and 8 all have the same color, say red, then either \(\mathbf {c}(7) = blue\) and \(\mathbf {c}(9) = green\), or \(\mathbf {c}(7) = green\) and \(\mathbf {c}(9) = blue\). Therefore, \(\{\mathbf {c}(5),\mathbf {c}(10)\} = \{blue,green\}\) and since c is adjacent to all three colors, we then obtain a contradiction. Now if vertices 4 and 8 have the same color, say red, then vertex 6 has color green and both 7 and 9 have color blue, a contradiction. Hence, either \(\mathbf {c}(4) = \mathbf {c}(6) \ne \mathbf {c}(8)\) or \(\mathbf {c}(8) = \mathbf {c}(6) \ne \mathbf {c}(4)\). By symmetry, we may assume that vertices 4 and 6 have the same color, say red, and that vertex 8 has color green. This implies that vertex 7 has color green, vertices 9 and 5 have color blue and vertex 10 has color red; but then, \(\mathbf {c}(c) = green \ne \mathbf {c}(b)\). This proves the first point of the claim. Observe that each coloring of b and c with distinct colors can be extended to a 3-coloring of \(H'\) and H.

As for the second point, since vertices 4 and 6 have color red, both 1 and 2 must have color green, and since vertex 8 has color green, vertex 3 must have color red. Consequently, \(\mathbf {c}(a) = blue = \mathbf {c}(b)\). \(\diamondsuit \)

We finally conclude the proof of Theorem 5. By Claim 1, if \(\mathbf {c}\) is a 3-coloring of \(G'\) then, for any path \(P_{uv}\) of \(\mathcal {P}\), we have \(\mathbf {c}(u_1) \ne \mathbf {c}(u_2)\) and \(\mathbf {c}(u_2) = \mathbf {c}(u_i)\) for all \(3\le i \le k\). Hence, \(\mathbf {c}\) induces a 3-coloring of G. Conversely, it is easy to see that any 3-coloring of G can be extended to a 3-coloring of \(G'\).    \(\square \)

Fig. 7.
figure 7

The gadget H (left) and a 0-bend CPG representation of it (right).

Fig. 8.
figure 8

Adding gadgets H and \(H'\).

Fig. 9.
figure 9

Locally adding gadgets to control the color of the vertices.

6 Conclusion

We conclude by stating the following open questions:

  1. 1.

    Are \(B_1\)-CPG graphs 5-colorable?

  2. 2.

    Can we characterize those planar graphs which are CPG?

  3. 3.

    Is Recognition \(\mathsf {NP}\)-complete for \(B_k\)-CPG graphs with \(k >0\)?