Recognizing IC-Planar and NIC-Planar Graphs

We prove that triangulated IC-planar and NIC-planar graphs can be recognized in cubic time. A graph is 1-planar if it can be drawn in the plane with at most one crossing per edge. A drawing is IC-planar if, in addition, each vertex is incident to at most one crossing edge and NIC-planar if two pairs of crossing edges share at most one vertex. In a triangulated drawing each face is a triangle. In consequence, planar-maximal and maximal IC-planar and NIC-planar graphs can be recognized in O(n^5) time and maximum and optimal ones in O(n^3) time. In contrast, recognizing 3-connected IC-planar and NIC-planar graphs is NP-complete, even if the graphs are given with a rotation system which describes the cyclic ordering of the edges at each vertex. Our results complement similar ones for 1-planar graphs.


Introduction
Graphs are commonly drawn in the plane so that the vertices are mapped to distinct points and the edges to Jordan curves connecting the endpoints. A drawing is used to visualize structural relationships that are modeled by vertices and edges and thereby make them easier comprehensible to a human user. Specifications of nice drawings of graphs and algorithms for their constructions are the topic of Graph Drawing [19,26,35].
There are several classes of graphs that are defined by specific restrictions of edge crossings in graph drawings. Edge crossings are negatively correlated to nice, and therefore, they should be avoided or controlled in some way. The planar graphs are the best known and most prominent example. Planarity excludes crossings and is one of the most basic and influential concepts in Graph Theory. Many properties of planar graphs have been explored, including duality, minors, and drawings [20], as well as linear-time algorithms for the recognition and the construction of straight-line grid drawings [23,33]. However, graphs from applications in engineering, social science, and life science are generally not planar. This observation has motivated approaches towards beyond-planar graphs, which allow crossings of edges with restrictions. A prominent example is 1-planar graphs, which were introduced by Ringel [32] in an approach to color a planar graph and its dual simultaneously. A graph is 1-planar if it can be drawn in the plane so that each edge is crossed at most once. 1-planar graphs have found  [31]. A 1-planar graph of size n has at most 4n − 8 edges [32] and K 6 is the maximum complete 1-planar graph. 1-planar graphs do not admit straight-line drawings [36], whereas 3-connected 1-planar graphs can be drawn straight-line on a grid of quadratic size with the exception of a single edge in the outer face [1]. Moreover, 1-planar graphs do not admit right angle crossing drawings [21], and conversely, there are right angle crossing (RAC) graphs that are not 1-planar. In other words, the classes of 1-planar and RAC graphs are incomparable. The recognition problem of 1planar graphs is NP-complete [24,27]. It remains NP-complete, even for graphs of bounded bandwidth, pathwidth, or treewidth [6], if an edge is added to a planar graph [15], and if the graphs are 3-connected and are given with a rotation system which describes the cyclic ordering of the neighbors at each vertex [4]. On the other hand, 1-planar graphs can be recognized in cubic time if they are triangulated [18] and even in linear time if they are optimal and have 4n − 8 edges [11].
1-planar graphs can also be defined in terms of maps [16][17][18]37]. Maps generalize the concept of planar duality. A map M is a partition of the sphere into finitely many regions. Each region is homeomorphic to a closed disk and the interior of two regions is disjoint. Some regions are labeled as countries and the remaining regions are lakes or holes. In the plane, we use the region of one country as outer face, which is unbounded and encloses all other regions. An adjacency is defined by a touching of countries. There is a strong adjacency between two countries if their boundaries intersect in a segment and a weak adjacency if the boundaries intersect only in a point. There is a k-point if k countries meet at a point. A map M defines a graph G so that the countries of M are in one-to-one correspondence with the vertices of G and there is an edge {u, v} if and only if the countries of u and v are adjacent. Then G is called a map graph and M is the map of G. Note that holes are discarded for the definition of map graphs. Obviously, a k-point induces K k as a subgraph. If no more than k countries meet at a point, then M is a k-map and G is a k-map graph. If there are no holes then M is hole-free. A graph is a hole-free 4-map graph if it is the map graph of a hole-free 4-map [16][17][18].
Chen et al [17,18] stated that the triangulated 1-planar graphs are exactly the 3-connected hole-free 4-map graphs. Their fundamental result is a cubictime recognition algorithm for 3-connected hole-free 4-map graphs. They also observed that the recognition problem of hole-free 4-map graphs can be reduced in linear time to the special case of 3-connected graphs. Hence, the recognition problem of 1-planar graphs is solvable in cubic time if the graphs are triangulated. We extend the algorithm to triangulated 1-planar graphs with (near) independent crossings. A graph is IC-planar (independent crossing planar) [2,13,28,38] if it has a 1-planar drawing in which each vertex is incident to at most one crossing edge and is NIC-planar (near independent crossing planar) [5,39] if two pairs of crossing edges share at most one vertex. If each pair of crossing edges is augmented to the complete graph K 4 , which is drawn as a kite as in Fig. 1(b), then a 1-planar drawing is IC-planar if each vertex is part of at most one kite and it is NIC-planar if each edge is part of at most one kite. It is known that IC-planar graphs have at most 13/4 n − 6 edges [28] and are 5-colorable [38]. The recognition problem is NP-hard, even for 3-connected graphs with a given rotation system [13]. IC-planar graphs admit straight-line drawings on a grid of quadratic size and right angle crossing drawings, which, however, may need exponential area [13]. Hence, every IC-planar graph is a RAC graph. NIC-planar graphs have at most 18/5 (n − 2) edges [5,39] and an NP-complete recognition problem. They admit straight-line drawings, but not necessarily with right angle crossings. In fact, there are NIC-planar graphs that are not RAC graphs, and vice-versa [5]. Hence, the classes of NIC-planar graphs and of RAC graphs are incomparable. Outer 1-planar graphs are another important subclass of 1-planar graphs that admit a 1-planar drawing with all vertices in the outer face [22]. Outer 1-planar graphs are planar [3] and can be recognized in linear time [3,25].
A drawn graph defines an embedding which is an equivalence class of drawings and consists of faces whose boundary consists of edges or half-edges between a vertex and a crossing point of two edges. There are several ways to augment 1-planar embeddings and graphs. Ringel [32] observed that each pair of crossing edges of a 1-planar embedding can be augmented to a complete graph K 4 that is embedded as a kite. This fact has been rediscovered in many works. A 1planar embedding of a graph G is plane-maximal if no planar edge can be added to G without violating 1-planarity or introducing multiple edges. However, the introduction of multiple edges may be useful at a separation pair. If there are two vertices s and t so that G − {s, t} decomposes into components H 1 , . . . , H r , then the augmented components H i + {s, t} are treated separately for a recognition [18] or a drawing [9]. Altogether, there are r − 1 copies of the edge between the separation pair {s, t}. An embedding is triangulated if each face is a triangle and is bounded by three (half-)edges (between a vertex and a crossing point). Clearly, a 1-planar embedding without separation pairs is triangulated if and only if it is plane-maximal. If multiple edges are added at a separation pair as described above, then triangulated and plane-maximal coincide on 1-planar embeddings.
A 1-planar graph G is triangulated (plane-maximal) if it admits a triangulated (plane-maximal) 1-planar embedding. It is planar-maximal if no edge e can be added to G so that G + e admits a 1-planar embedding in which e is planar. Finally, G is maximal if G + e is not 1-planar, maximum or densest if G + e violates the upper bound of the number of edges of 1-planar graphs and optimal if the number of edges exactly meets the upper bound of 4n − 8. Hence, a graph in a graph class G is maximal if there is no supergraph in G with the same set of vertices and a proper superset of edges, and maximum if there is no graph in G of the same size and with more edges. Similar notions apply to planar, IC-planar, and NIC-planar graphs. Clearly, these concepts coincide for planar graphs whereas they differ for IC-planar, NIC-planar and 1-planar graphs. First, note the difference between plane-maximal and planar-maximal graphs. As an example, remove an edge from the complete graph on five vertices and consider K 5 − e which is a maximal planar graph. Every planar embedding of K 5 − e is plane-maximal 1-planar. However, the removed edge e can be added and drawn planar if a K 4 subgraph of K 5 − e is drawn with a pair of crossing edges. Hence, K 5 − e is plane-maximal 1-planar and not planar-maximal 1-planar. Similarly, every triangulated planar graph of size at least five is plane-maximal and not planar-maximal (or maximal) 1-planar. Bodendiek et al. [7] showed that densest 1-planar graphs have 4n − 8 edges and that such graphs, called optimal, exist for n = 8 and all n ≥ 10 [8]. The upper bound was rediscovered in many works. Bodendiek et al. also observed that there are maximal 1-planar graphs that are not optimal. The gap in the number of edges of maximal 1-planar is quite large, as shown by Brandenburg et al. [14], who found sparse maximal 1-planar graphs with 45/17 n − 84/17 edges. Similarly, there are sparse maximal IC-planar graphs with 3n − 5 edges and sparse maximal NIC-planar graphs with 16/5 (n − 2) edges, and both bounds are tight [5]. There are optimal IC-planar graphs only for n = 4k and optimal NIC-planar graphs only for n = 5t + 2 and such graphs exist for all k ≥ 2 [38] and all t ≥ 2 [5]. Maximum IC-planar graphs with 13/4 n − 6 edges exist for all n ≥ 5 and there are maximum NICplanar graphs with 18/5(n − 2) edges for n = 5t + i and i = 2, 3 [5]. Hence, the sequence of restrictions from triangulated to optimal is proper for 1-planar, IC-planar, and NIC-planar graphs.
Finally, note that triangulated IC-planar (NIC-planar) embeddings do not admit separation pairs so that the embeddings are in normal form with a kite at each pair of crossing edges [1] and planar triangles for the other faces. There is a planar generalized dual graph if each kite (and also each planar tetrahedron) is represented by a special node [5].
In this work we extend the cubic-time algorithm of Chen et al. [18] for the recognition of triangulated 1-planar graphs to triangulated IC-planar and NICplanar graphs. We call the algorithms A, B IC and B N IC , respectively. Our algorithms are presented as a program and consist of three parts. They compute an edge coloring and a boolean formula which is used to test IC-and NIC-planarity.
The paper is organized as follows. Section 2 describes basic definitions. In Section 3 we present our algorithm and we show how to solve IC-and NICplanarity in Section 4. We conclude in Section 5 with some open problems.

Preliminaries
We consider undirected graphs G = (V, E) and assume that the graphs are simple and 2-connected, unless otherwise stated. The subgraph induced by a subset U of vertices is denoted by G[U ]. For convenience, we omit braces and write G[u 1 , . . . , u r ] if U = {u 1 , . . . , u r }. The subgraph of G induced by the vertices of subgraphs H and K is denoted by H + K, and similarly for G − H, except if H is an edge, which is removed from G − H whereas the endvertices remain.
A drawing of G maps the vertices to distinct points in the plane and each edge {u, v} to a Jordan arc connecting the points of u and v. Two edges cross if their Jordan arcs intersect. A planar drawing excludes edge crossings and a 1planar drawing admits at most one crossing per edge. A crossings subdivides an edge into two half-edges. An embedding E(G) is an equivalence class of drawings and specifies edge crossings and faces. The planarization of an embedding E(G) is an embedded planar graph which is obtained by taking each crossing point as a new vertex and half-edges as new edges.
A planar embedding partitions the plane (or the sphere) into faces or regions, called a map [17,18]. Two faces are adjacent if their boundaries intersect. The intersection is a segment or just a common point. A hole-free map graph is defined by a one-to-one correspondence between faces and vertices and between adjacencies and edges. There is a k-map graph if at most k regions meet at a point of a map. The complete graph on four vertices K 4 plays a crucial role in 1-planar, ICplanar and NIC-planar graphs. It admits two embeddings [29], as a tetrahedron or as a kite with a pair of crossing edges, see Fig. 1. The embedding as a tetrahedron is not necessarily planar. A planar edge can be covered by a kite so that an edge is a crossing edge of a kite, see Figs. 5(a) and 5(b). The cubic-time recognition algorithm for hole-free 4-map graphs of Chen et al. [18] searches all K 4 subgraphs κ of the given graph and checks whether κ must be embedded as a kite or as a tetrahedron. This can be determined to a large extend, but it is not unique, as a K 5 illustrates. The complete graph K 5 has five embeddings (up to graph automorphism) [29] as displayed in Fig. 2, but only one of them is 1-planar. If the outer face is fixed, then there are three 1-planar embeddings with one of the outer edges in a kite, see

Recognition
For the recognition of triangulated IC-planar and NIC-planar graphs we extend algorithm A of Chen et al. [18]. Recall that the 3-connected hole-free 4-map graphs are exactly the triangulated 1-planar graphs. Our algorithm B extends A by an edge coloring and a boolean formula. Algorithm A marks an edge if it is planar at the actual stage of the algorithm. A marked edge could have been crossed at an earlier stage, in which case it is crossed in the computed 1planar embedding. This divergence is due to the fact that algorithm A removes one crossing edge if it detects a pair of crossing edges. The remaining crossed edge is marked and is treated as planar. Our edge coloring records each decision and tells whether an edge is planar or crossed in every triangulated 1-planar embedding, or whether this is uncertain and depends on a particular embedding. The uncertainty is expressed by a boolean formula such that there is a oneto-one correspondence between feasible embeddings and truth assignments. An embedding is feasible if it is triangulated and IC-and NIC-planar, respectively. We prove the following result: There is a cubic-time algorithm that checks whether a graph G is a triangulated 1-planar graph. It returns an edge coloring of G, from which one obtains a partial embedding of a spanning subgraph of G, and a boolean formula η such that the IC-extension (NIC-extension) η + of η is satisfiable if and only if the embedding of G is IC-planar (NIC-planar). Otherwise, the algorithm returns false and stops with a failure.
Algorithm B is the program of algorithm A of [18] with a minor simplification. Algorithms B IC and B N IC specialize B to IC-planar and NIC-planar graphs, respectively. They stop immediately if there is a violation of IC-or NIC-planarity. In each step the algorithms add a clause to a CNF formula η. The boolean formulas for IC-planar and NIC-planar graphs have the same structure, however, the boolean variables and the evaluation are different. A boolean variable is associated with a vertex for IC-planar graphs and with an edge for NIC-planar graphs. For every K 4 subgraph κ of the input graph G, the clause α(κ) = (a κ ∧ b κ ∧ c κ ∧ d κ ) expresses that κ is embedded as a kite with a pair of crossing edges and the boolean variable x κ is assigned the value true. Here, x ∈ {a, b, c, d} is a vertex of κ in the IC-planar case, and x is a planar edge of κ in the NIC-planar case. Feasibility is granted by IC-and NIC-extensions of the form (¬x κ ∨ ¬x κ ) for every vertex (edge) x and kites κ and κ that may include x.
Algorithm A systematically checks all K 4 subgraphs κ of the given input graph G. It checks gadgets in a fixed order and tries to determine whether κ must be embedded as a kite or as a tetrahedron, and so do algorithms B, B IC and B N IC . In most cases there is an unambiguous decision. However, a separating edge only tells that there is a kite, but it does not fix its position. Another ambiguity comes from small graphs which result from a partition by a separating 3-cycle or 4-cycle. Input graphs of size at most eight are checked by inspection. For example, the complete graph K 5 with a fixed outer face has three embeddings with kites κ 1 , κ 2 , and κ 3 , as illustrated in Fig. 3, and the clause α(κ 1 ) ∨ α(κ 2 ) ∨ α(κ 3 ) expresses the three options. For an efficient evaluation the clause is simplified.
The specialization concerns the steps of A with a separating triangle, M C 5 and M C 4 . These gadgets are described below. A vertex is incident to two kites at a separating triangle, which violates IC-planarity. The M C 5 step searches K 5 and is vacuous, even for 1-planar graphs, as proved in Lemma 2, and most subcases of the M C 4 step violate IC-and NIC-planarity. Then algorithms B IC and B N IC return false and stop. In addition, the set of all IC-planar (NICplanar) embeddings of graphs of size at most eight is computed and expressed by a simplified boolean formula with variables for the vertices or edges of the outer face.
Next, we explain the edge coloring and the boolean formula.
Definition 1. An edge of a 1-planar graph G is colored black if it is a planar edge in every triangulated 1-planar embedding E(G). Two edges e and f are colored red and blue, respectively, if e and f cross in every triangulated 1planar embedding. In edge is colored orange if it is crossed and the candidates for a crossing are colored cyan. Finally, grey edges are unclear.
For an uncolored edge {a, b} let C[a, b] be the set of uncolored edges {x, y} so that the induced subgraph G[a, b, x, y] is a K 4 . Such edges are called crossable edges in [18].
The black, red, blue, and orange edges are decided, whereas a cyan and a grey edge may be planar in one 1-planar embedding and crossed in another. Grey edges appear only in small subgraphs, such as K 5 in Fig. 3. A partial coloring χ on a subset of edges of G is extended step by step such that some uncolored edges are colored. Here, blue and cyan overrule black or grey and blue and cyan edges keep their color. There is an error, otherwise, e.g., if a black edge shall be colored blue or red.

Definition 2.
A coloring γ of a set of edges F ⊆ E extends a partial edge coloring χ of G if colored edges keep their color and an uncolored edge e ∈ F takes the color of γ. If γ and χ disagree, then γ(e) = "black" or "grey" and χ(e) = "blue" or "cyan". Otherwise, there is a conflict between γ and χ, which is reported as a failure.
The boolean formula η is build up step by step as a conjunction of clauses during a run of our algorithms. For every K 4 subgraph κ = G[a, b, c, d], which may be embedded as a kite, let α(κ) = (x 1 κ ∧x 2 κ ∧x 3 κ ∧x 4 κ ). In case of IC-planarity, x 1 , . . . , x 4 are the vertices of κ, and they are the planar edges of κ in case of NIC-planarity. Each vertex (edge) may be part of at most one kite such that each variable x κ is true for at most one kite κ. This is expressed by the IC-and NIC-extension, respectively.
Let's recall algorithm A on triangulated 1-planar graphs which are 3-connected hole-free map graphs. For the formal properties of each step, its computation, and the correctness proof we refer to [18]. Algorithm A "makes progress" (i) by a separation and (ii) by a crossing removal.
There are separating 3-cycles and separating 4-cycles in G. Each such cycle C partitions G − C into an inner and an outer component G in and G out . At the time of the separation, the edges of C are planar and the subgraphs G in + C and G out + C can be treated separately [18]. If C is a 4-cycle, then a chord f must be added to the subgraphs for a triangulation, and f must be chosen properly, such that it is new for the remaining subgraph. The chord is removed if the subgraphs are merged later on. Some edges of C were kite-covered before and were crossed by other edges that were removed in an earlier step of the algorithm. Then some edges of C are colored blue or cyan, whereas A treats them as black edges.
Algorithm A recursively searches for gadgets, namely, separating 3-cycles, separating edges, separating 4-cycles, separating triples, separating quadruples, separating triangles, M C 5 and M C 4 , in this order. The gadgets are described below. Hence, if A considers a separating edge, then there are no separating 3cycles and the graph under consideration is 4-connected. There is neither of the other gadgets if M C 4 is applied. The search for the gadgets in the given order simplifies the case analysis and implies that decisions hold for all triangulated 1-planar embeddings.
In each case, algorithm A finds edges that are crossed in a 1-planar embedding or finds edges that can be treated as planar at this stage. One edge from a pair of crossing edges is removed to make progress towards planarity. If A does not fail, then it terminates at a triangulated planar graph or at a small graph of size at most eight.
The decisions of A do not uniquely determine a 1-planar embedding. For example, if there is a separating edge e, then e has the choice among several crossable edges. The case resembles a graph decomposition at a separation pair. Also, K 5 has three embeddings if there is a planar outer 3-cycle. A final ambiguity comes from each pair of crossing edges where A removes one of them to make progress. The choice has an effect on the ongoing computation process. One may aim at using separating 3-and 4-cycles in the next step by removing the edges of C[a, b] whereas the removal of {a, b} aims at 4-connected planar graphs.
The choice does not affect the "yes" or "no" decision on a triangulated 1-planar graph.
IC-and NIC-planarity need more information on all 1-planar embeddings of the given graph which is provided by an edge coloring and a boolean formula.
is disconnected, see  We use the following properties of algorithm A.
Lemma 1. Let G be a triangulated 1-planar graph with |G| > 8. Proof. Algorithm A partitions G into an inner and an outer component at a separating 3-or 4-cycle C and marks the edges of C (Lemma 3.5 of [18] The search for maximal complete subgraphs of size five and M C 4 complete algorithm A. However, as stated before, K 5 subgraphs have a unique 1-planar embedding which is detected at an earlier stage. Lemma 2. The M C 5 step of algorithm A is vacuous if G is a triangulated 1-planar graph. Proof. There are five embeddings of K 5 [29] and only the one in Fig. 2(a) is 1planar. The embedding consist of a kite and a top vertex t (called crust in [18]). The edges incident with t can be planar or are kite-covered, whereas the outer edges of the kite are planar. Hence, there is a separating 3-cycle, triple, or triangle and A takes these gadgets with higher priority than M C 5 .
In consequence, we must consider embeddings of K 5 only as part of a small subgraph H of size at most eight that is obtained by a partition of a separating 3-or 4-cycle. The outer edges of H are treated as planar although they may be colored black, blue or cyan. For example, suppose there is a separating triangle Algorithm A finally applies M C 4 and checks whether the detected K 4 must be embedded as a tetrahedron or as a kite. However, at this stage of the algorithm, the embedding as a tetrahedron implies that all edges are kite-covered. A planar tetrahedron is detected in the first step since there is a separating 3-cycle and there is a separating triangle or a separating triple, otherwise. Hence, only three cases remain, as described in Section 9.1 of [18]. Lemma 3. If M C 4 applies to algorithm A then the K 4 subgraph is 1. a completely kite-covered tetrahedron, see Fig. 6(a) 2. an SC-graph, see Fig. 6(b), or 3. a kite, see Fig. 1(b), and they are checked in this order. A crossing edge of each of the six kites it removed to make progress if a completely kite-covered tetrahedron is detected. The SC-graph plays a central in the graph reduction system of Schumacher [34] and Brandenburg [11]. Here a crossing edge is removed from each of the three kites. Plain kites that are surrounded by planar subgraphs are common in IC-planar and in NIC-planar graphs, as the analysis of maximal NIC-planar graphs shows [5].  The subroutine merge reverts the partition into an inner and an outer subgraph, takes the edge coloring of the subgraphs and combines the boolean formulas by a conjunction. It ignores the chord that was added for the triangulation if there is a partition by a separating 4-cycle. If {x 1 , y 1 }, . . . , {x r , y r } are the crossable edges of a separating edge {a, b}, then σ (a, b, C[a, b] Algorithm final-check takes any 1-planar embedding and makes progress by removing one edge from each pair of crossing edges. Uncolored edges are colored grey although the used embedding determines pairs of crossing edges. A grey edge may be planar in one 1-planar embedding of G and crossed in another.
The correctness of algorithms B uses the following properties of Algorithm A, as proved in [18].

Lemma 4. If E(G)
is a triangulated 1-planar embedding of G, then algorithm B succeeds and returns a triangulated planar spanning subgraph, an edge coloring, and a boolean formula η such that each black edge is planar in E(G), each red, blue, and orange edge is crossed in E(G), there are pairs of red and blue edges that cross, and each orange edge crosses a cyan one. Moreover, one edge from each pair of crossing edges is red, orange, or grey.
Proof. By the assumptions, G is a triangulated 1-planar graph and algorithm A succeeds on G. Since B extends A, it also succeeds, since M C 5 does not apply, as shown in Lemma 2. Then B provides the edge coloring as stated. All K 4 subgraphs are scanned and their embedding is classified as a kite, as a planar tetrahedron (after a separating 3-cycle), or as a tetrahedron with kite-covered edges. One edge of each detected kite is colored red or orange, or it is colored grey in a small subgraph.

Specialization to IC-and NIC-Planarity
For the test of IC-and NIC-planarity we must specialize M C 4 and final-check. A completely kite-covered K 4 is not IC-planar and the SC-graph is not NICplanar. If such a subgraph is encountered, then the recognition algorithm for IC-planarity (NIC-planarity) fails and the modified algorithm returns false and stops.
If G is a small graph of size at most eight, then consider all IC-planar (NICplanar) embeddings of G that extend the given partial coloring. Such graphs occur at separating 3-cycles and separating 4-cycles and have an outer cycle C whose edges are colored black, blue, or cyan. If an edge e of C is colored blue, then e is crossed by an edge f , which is colored red and is not part of the evoked input graph G. Then there are black edges in G which are part of the kite with the pair of crossing edges {e, f }. Such situations decrease the number of ICplanar (NIC-planar) embeddings of G and reduce ambiguities. An ambiguity in the embeddings is due to K 5 , which may choose any edge of an outer triangle as part of its kite, as shown in Fig. 3. In the IC-planar case, we obtain the formula (a κ1 ∧ b κ1 ) ∨ (a κ2 ∧ c κ2 ) ∨ (b κ3 ∧ c κ3 ), where a, b, c are the vertices of the outer face and κ 1 , κ 2 , κ 3 are the three possible kites. For NIC-planarity be obtain (e κ1 ∨ f κ2 ∨ g κ3 ), where e, f and g are the edges of the outer face. Note that edge h between the two inner vertices is in each of the three kites, but h is ignored for the boolean formula. It is internal and its three occurrences would violate the special structure of the boolean formula η that is used for an efficient evaluation. Similarly, if G has eight vertices with vertices a, b, c, d in the outer face (ignoring the added chord) and internally two K 5 including the vertices a, b, c and b, c, d, then there are two IC-planar embeddings of G and the formula is , where κ and κ are two kites. A NIC-planar embedding uses the diagonal {b, c} for one kite and one outer edge for the second kite so that we obtain the formula (e κ1 ∨ f κ2 ∨ g κ3 ∨ h κ4 ) where e, f, g, h are the edges of the outer face and κ 1 , . . . , κ 4 are possible kites.
The extended version of algorithm final-check in B IC (B N IC ) computes all IC-planar (NIC-planar) embeddings of the small graph G of size at most eight that extend the given partial coloring. Each embedding is expressed by a boolean formula in CNF using only variables for the vertices (edges) in the outer face. These formulas are combined by a disjunction to express the set of all IC-planar (NIC-planar) embeddings.

Algorithm 4: Algorithm final-check for IC-planar and NIC-planar Graphs
Input: A 3-connected graph G with a partial edge coloring and a boolean formula η. Output: A planar subgraph of G with an edge coloring and η. 1 if G is a triangulated planar graph then The boolean formula η collects the clause α(κ) of all possible kites κ, but it does not express IC-and NIC-planarity and a mutual exclusion of two kites with a common vertex and edge, respectively. Therefore, we extend η to η + , and we finally transform η + into η * for an efficient evaluation. Then E(G) is a 1-planar embedding in which all black edges are planar and all red, blue, and orange edges are crossed. For every K 4 subgraph which cannot be embedded planar there is a clause expressing a crossing. Consider a valid truth assignment of η + . If a clause of α(κ) of η resp. η + is satisfied by x κ = true, then x κ = false for all κ such that κ and κ share vertex (edge) e, which implies that the 1-planar embedding E(G) is IC-planar (NIC-planar). Conversely, if G is triangulated IC-planar (NICplanar), then algorithms A, B and B IC (B N IC ) succeed. There is an embedding E(G) that corresponds to the computed edge coloring. The extension η + of the computed boolean formula η is satisfied by a truth assignment x κ = true for each kite of E(G), since each vertex (edge) x is in at most one kite.
Algorithm A runs in cubic time [18], and so do B, B IC and B N IC . For a cubic time recognition it remains to show that the satisfiability problem of η + can be solved in cubic time. This is not immediately clear, since the algorithms collect clauses for the CNF formula η. Fortunately, η and η + have a special structure which is used for an efficient evaluation.

Evaluate IC-planar Formulas
First, consider the IC-planar case. There is a disjunction at two places: (i) a separating edge and (ii) small graphs.
If e = {a, b} is a separating edge with candidates f 1 , . . . , f r in C[a, b] for a crossing, then the formula σ (a, b, C[a, b]) expresses all possible kites from which one is realized. Since the vertices a and b are in the kite, σ(a, b, C[a, b] . . , r and r > 1.
If G is a small graph after a separating 3-or 4-cycle C, then IC-planar embeddings can be expressed by a 2SAT formula with variables for the vertices of C.
Lemma 5. If G is an IC-planar graph without a separating edge, then the ICextension η + of the formula η computed by algorithm B IC is equivalent to a 2SAT formula.

Proof. The boolean formula of a kite
and α(κ) is added to η at a separating triple, a separating quadruple, and at a kite in M C 4 . Two subexpressions are combined by a conjunction at a separating 3-and 4-cycle.
It thus remains to show that the IC-extension of a formula η for a small graph H is equivalent to a 2SAT formula, and is replaced by the 2SAT formula for further computations. Graph H is obtained by a separating 3-or 4-cycle. Then the edges of the cycle are black, blue or cyan and are treated as planar. Since blue or cyan imposes further restrictions we suppose they are black. First, suppose there is a 3-cycle with vertices a, b, c. If there is a planar embedding, then true is returned. Otherwise, if every embedding of G contains a kite, then Fig. 3. The IC-extension adds the clauses (¬a κ1 ∨ ¬a κ2 ), (¬b κ1 ∨ ¬b κ3 ) and (¬c κ2 ∨ ¬c κ3 ). The combined subexpression is equivalent to the 2SAT formula (a κ ∨ b κ ) ∧ (a κ ∨ c κ ) ∧ (b κ ∨ c κ ) for a new virtual kite κ and is replaced by this formula. If G has 6, 7 or 8 vertices, then η is a 2SAT formula, since a single kite contains at most two of the outer vertices or there are two kites and 8 vertices and the formula is equivalent to (a κ ∧ b κ ∧ c κ ). Similarly, if H is obtained by a separating 4-cycle C = (a, b, c, d), then there is a K 5 with three outer vertices a, b, c as above, or η is a 2SAT formula. In particular, if H contains two K 5 with vertices a, b, c, u, v and a, c, d, x, y, The satisfiability problem for η + can be reduced to a series of 2SAT satisfiability problems, which altogether can be solved in linear time in the length of η + . This technique was used in [13]. Lemma 6. There is a linear time algorithm (in the length of η + ) to test the satisfiability of the IC-extension η + of a triangulated IC-planar graph.
Proof. Consider the recursive construction of the boolean formula η by algorithm B IC . All subexpressions are in 2SAT form or are replaced by an equivalent 2SAT formula as shown in Lemma 5, except if there is a separating edge. We proceed by induction on the depth of the formula. Consider the first separating edge {a, b} and the computed formula σ(a, b, C[a, b]). As stated before, σ(a, b, . . . , f r ) in this order according to the rotation system at a. Then a, b, x 1 , y r are the outer vertices, and x 2 , . . . , x r , y 1 , . . . , y r−1 are inner vertices. We wish to use a pair of inner vertices (together with a and b) for the kite. For i = 2, . . . , r − 1 check the satisfiability of the subexpression η + (a, x i , b, y i ) of η + that corresponds to the subgraph H of G that is separated by the 4-cycle C = (a, x i , b, y i ). Since H has no separating edge, η + (a, x i , b, y i ) is equivalent to a 2SAT formula, whose satisfiability is checked in linear time. If η + (a, x i , b, y i ) is satisfiable for some i, then replace σ(a, b, C[a, b]) by (a κ ∧ b κ ). Otherwise, check the satisfiability of η + (a, x 1 , b, y 1 ) and of η + (a, x r , b, y r ). If neither of them is satisfiable, then η + is not satisfiable and the given graph G is not IC-planar. If only one is satisfiable, say η + (a, A 1-planar graph of size n has at most n − 2 kites, and the bound is achieved by optimal 1-planar graphs with 4n−8 edges [8,34]. Hence, the boolean formula η has length O(n). However, the IC-extension may add up to O(n 2 ) subexpressions of the form (¬x κ ∨ ¬x κ ), for example, if x is the center of a star of K 5 , as illustrated in Fig. 7. In consequence, the satisfiability check of η + takes linear time in the length of the formula and at most quadratic time in the size of the input graph. This is less than the cubic running time of algorithm B IC .
In summary, we obtain: Theorem 3. Triangulated IC-planar graphs can be recognized in cubic time.

Evaluate NIC-planar formulas
Algorithm B N IC extends algorithm B and stops with a failure if M C 4 detects an SC-graph. In addition, it computes all NIC-planar embeddings of small graphs and expresses them by a boolean formula η. A boolean variable has the form e κ for some edge e and a kite κ containing e as a planar edge. If G is a small graph that results from a separating 3-or 4-cycle C, then only the edges of C are taken into account. An inner edge of a K 5 occurs in three kites and does not satisfy the next lemma.
Lemma 7. For every edge e with an occurrence of a variable e κ in η there are at most two variables e κ and e κ in η.
Proof. First, observe that each variable e κ occurs once in η since algorithms A and B N IC check each K 4 exactly once and B N IC introduces a boolean variable e κ if edge e is a planar edge of candidate kite κ, which is a unique event.
Second, all steps of algorithm B N IC introduce at most two variables e κ and e κ for two candidate kites κ and κ , except if G is a small graph of size at most eight. Let C be the edges of the outer cycle of G. Then C is a 3-cycle or a 4-cycle and G and C are obtained from the separating 3-cycle and 4-cycle steps of the algorithm, except if the input graph is small, which is checked by exhaustive search. Suppose that the edges of C are colored black. Otherwise, the possible NIC-planar embeddings of G are more restricted.
Assume that G must be embedded with at least one kite. First, suppose that C is a 3-cycle with edges e 1 , e 2 and e 3 . If G = K 5 , then exactly one edge e of C is part of a kite, as illustrated in Fig. 3, and all NIC-planar embeddings are expressed by the boolean formula α = e 1 κ1 ∨ e 2 κ2 ∨ e 3 κ3 . A graph G of size six with outer cycle C is NIC-planar if there is a fixed kite including one edge of C or there is a K 5 with one of two edges of C. Hence, α = e κ or α = e κ ∨ e κ for edges e, e ∈ {e 1 , e 2 , e 3 }. If G has size seven, then a NIC-planar embedding has up to two kites. At least one kite is fixed and the other is part of a K 5 , see Fig. 8. The possible NIC-planar embeddings are expressed by α = e(κ) ∧ e (κ ) if both K 4 are fixed and by α = e 1 (κ 1 ) ∧ (e 2 (κ 2 ) ∨ e 3 (κ 3 )), otherwise. Similarly, if there is only one kite that needs an edge of C, then α = e(κ) or α = e(κ) ∨ e (κ ) express these embeddings. Finally, if G has size eight, then it has up to two fixed K 4 or two outer edges may belong to a K 5 and the other edge to a fixed K 4 such that α = e 1 (κ 1 ) ∧ e 2 (κ 2 ) or α = e 1 (κ 1 ) ∧ (e 2 (κ 2 ) ∨ e 3 (κ 3 )) or α is a subexpression thereof.
Similarly, if C is a 4-cycle with edges e 1 , e 2 , e 3 , e 4 , then a graph of size eight can host two K 5 and at most two kites. Each K 5 indices a kite and one of the two K 5 shall form a kite using only inner edges including the diagonal, see Fig. 9. These NIC-planar embeddings are expressed by α = (e 1 (κ 1 ) ∨ e 2 (κ 2 ) ∨ e 3 (κ 3 ) ∨ e 4 (κ 4 )). Clearly both K 4 can be fixed using up to three edges of C. Each option is expressed by a boolean formula that uses a variable e κ for each edge e of C at most once. Proof. Consider the formulas η and η + that are obtained by algorithm B N IC and the NIC-extension. Set a variable e(κ) = true if there is a single variable e(κ) for some edge e in η. Then there is no NIC-extension. Simplify η and η + accordingly. Otherwise, there are two variables e(κ) and e(κ ) with κ = κ in η and there is the NIC-extension ¬e(κ) ∨ ¬e(κ ). Keep the first occurrence e(κ) in η and replace the second occurrence e(κ ) by ¬e(κ) and omit the NIC-extensions. Since each edge e occurs in two variables e(κ) and e(κ ), this transformation preserves the equivalence of the boolean formulas. Let η * denote the resulting formula. Then η * is satisfiable if and only if there is no complementary pair (x, ¬x) in some clause, which can be checked in linear time. Each simplification of η can be done in constant time. Hence, the satisfiability test of η, η + and η * takes linear time.
As before, there are at most O(n) kites such that the length of η is linear in the size of the given graph G. Each edge e belongs to at most two kites. Thus, the NIC-extensions adds at most O(n) 2SAT clauses. By Lemma 8 the satisfiability check of η + takes linear time in the size of the graph. This is dominated by the running time of algorithm B N IC , and we can conclude: Theorem 4. Triangulated NIC-planar graphs can be recognized in cubic time.

Embeddings
We can generalize Thms. 3 and 4 to graphs G whose 3-connected components are triangulated IC-planar and NIC-planar. Consider a separation pair {u, v} of G and components H 1 , . . . , H r for some r > 1 which each contain the vertices u and v and the edge e = {u, v}. Then G is IC-planar if and only if each H i for i = 1, . . . , r is IC-planar and each of u and v occurs in at most one kite. This is checked as follows: Let algorithm B IC return the boolean formula η i on H i . If η i has a variable x(κ) for x ∈ {u, v} and some kite κ, then set x(κ) = false. If thereafter the IC-extension η + i is not satisfiable, then vertex x is needed in H i . Graph G is not IC-planar if there are at least two such H i . Accordingly, if v is an articulation vertex with components J 1 , . . . , J s for some s > 1, then check each component J i + v and check that v is in a kite of at most one component. Clearly, a graph is IC-planar if so are its disconnected components.
Similarly, G is NIC-planar if and only if each 2-connected component H i is NIC-planar and edge e occurs in at most one kite, which is checked as before.
Note that the decomposition of a graph at its separation pairs corresponds to the introduction of holes in maps [10]. We can summarize: There is a cubic-time algorithm to test whether a graph is ICplanar (NIC-planar) if each 3-connected component is triangulated 1-planar.
The algorithms B, B IC and B IC color the edges of a triangulated 1-planar graph such that black edges are always embedded planar, red, blue and orange edges are crossing edges, and the status of cyan and grey edges is open. Nevertheless, the algorithms cannot determine an embedding. There are triangulated IC-planar and NIC-planar graphs with exponentially many embeddings, as illustrated in Figs. 10 and 11. These graphs are maximal in their class. If B is applied to these graphs, it finds separating 3-cycles and many small graphs with a K 5 , which each allow for at least two embeddings.

Maximal Graphs
Obviously, we can test maximality by exhaustive search on graphs G + e, such that G is 1-planar and G + e is not. In the planar-maximal case, edge e is colored black, and therefore must be embedded planar.
Theorem 6. For a graph G it takes O(n 5 ) time to test whether G is planarmaximal and maximal 1-planar, IC-planar, and NIC-planar, respectively. There are special linear time algorithm for optimal 1-planar graphs [12] and for NIC-planar graphs [5] which use the particular structure of optimal graphs. Recall that there are optimal IC-planar (NIC-planar) graphs only for values n = 4k + 4 (n = 5k + 2) and k ≥ 1.
Theorem 7. For a graph G it takes O(n 3 ) time to test whether G is maximum (optimal) IC-planar (NIC-planar).
Proof. A graph G is maximum (or densest) IC-planar if G has 3.25 n − 6 edges and is triangulated IC-planar. Similarly, test whether G is triangulated NICplanar and has the maximum number of edges of edges of NIC-planar graphs of size b, which is d(n) = 3.6 (n − 2) − where = 0, 1 and = 0 for n = 5k + i and i = 2, 3 and k ≥ 2. The value of epsion for all n is not yet known.

NP-Completeness
Finally, we improve upon the NP-hardness proofs of 1-planarity. We prove that for every instance α of planar 3-SAT there is a graph G α such that G α is IC planar if α is satisfiable and α is satisfiable if G α is 1-planar, even if G α is 3-connected and is given with a rotation system. In consequence, we obtain: Theorem 8. For a graph G it is NP-complete to test whether G is IC-planar (NIC planar), even if G is 3-connected and is given with (or without) a rotation system.
Proof. We combine and generalize the NP-hardness results of Auer et al. [4] on 3-connected 1-planar graphs and of Brandenburg et al. [13]. Both approaches reduce from planar 3-SAT [30] and use gadgets with a unique embedding and the membrane technique.
We replace the U -graphs from [4] by M + -graphs which are modified grid graphs with a sequence of free connection vertices in the outer face, and are drawn as circles in Fig. 12. Our M + -graphs extend the M -graphs of [13] by further edges which yield a triangulation except for the side with the connection vertices. Obviously, M + -graphs are IC-planar, and even more, M + -graphs have a unique 1-planar embedding if the connection vertices are in the outer face. The uniqueness is obtained by using Algorithms A or B on an extension of an M +graph to a triangulated graph N which has a new vertex z in the outer face so that z is connected with each connection vertex. Only M C 4 with a kite applies to N . Hence, N has a unique 1-planar embedding. Now we can use the gadgets from the NP-hardness proof of [13] with M + graphs instead of M -graphs. For every planar 3-SAT instance α construct a graph G α . Then G α is 3-connected IC-planar if the instance of planar 3-SAT is satisfiable. The rotation system can directly be derived from the embedding, and it is unique. Conversely, if G α is 1-planar, then it is IC-planar and α is satisfiable.

Conclusion
We have shown that triangulated, (planar) maximal, maximum and optimal ICplanar and NIC-planar graphs can be recognized in at most O(n 5 ) time. Similar bounds are known for 1-planar graphs. On the other hand, the recognition problem remains NP-hard if the graphs are 3-connected. However, the complexity of the recognition problem for 4-and 5-connected IC-planar and NIC-planar graphs remains open.