1 Introduction

1.1 Embedding Graphs in 3-Space

A seminal result of Hopcroft and Tarjan [14] from 1974 is that there is a linear-time algorithm for testing planarity of graphs. This is just one of a host of results on embedding graphs in surfaces. These problems are of both practical and theoretical interest. The practical issues arise, for instance, in problems concerning VLSI, and also in several other applications of “nearly” planar networks, as planar graphs and graphs embedded in low genus surfaces can be handled more easily. Theoretical interest comes from the importance of the genus parameter of graphs and from the fact that graphs of bounded genus naturally generalize the family of planar graphs and share many important properties with them. Recently, new and nontrivial linear-time algorithms concerning graph embeddings have appeared [18, 22]. In addition, Mohar [33, 34] gave a linear-time algorithm for testing embeddability of graphs in an arbitrary surface and constructing an embedding, if one exists. This result generalizes planarity algorithms [4, 14, 52]. Mohar’s algorithm is further simplified in [19].

In [41], Robertson and Seymour proved that for any fixed graph H there is a cubic-time algorithm for testing whether H is a minor of a given graph G. This implies that there is an O(n 3) algorithm for deciding membership in any minor-closed family of graphs, because such a family can be characterized by a finite collection of excluded minors [42]. Unfortunately, this approach is not explicit. More precisely, the graph minor theorem is not constructive; in general, we do not know how to obtain an excluded minor characterization of a given minor-closed family of graphs. In addition, Robertson and Seymour’s algorithm solves the decision problem, but it is not apparent how to construct, e.g., an embedding from their algorithm.

In this paper, we consider embeddings of graphs in \(\mbox {{$\mathbb {R}$}}^{3}\), where all embeddings are piecewise linear. There are many minor-closed families of graphs that arise in the study of topological problems. An illustrative example is the class of linklessly embeddable graphs. We say that a pair of vertex-disjoint cycles drawn in \(\mbox {{$\mathbb {R}$}}^{3}\) is unlinked if there is a 2-dimensional diskFootnote 1 in \(\mbox {{$\mathbb {R}$}}^{3}\) that contains the first cycle and is disjoint from the other one. Otherwise, the two cycles are linked . Intuitively, if two cycles in \(\mbox {{$\mathbb {R}$}}^{3}\) are linked, we cannot contract one into a single point without cutting the other. By a linkless embedding we mean an embedding of a graph in \(\mbox {{$\mathbb {R}$}}^{3}\) in such a way that no two vertex-disjoint cycles are linked. Linkless embeddings were first studied by Conway and Gordon [8]. An algorithmic problem concerning linkless embeddings is studied by Motwani, Raghunathan and Saran [36], who gave a partial result for linkless embeddings and its algorithmic applications.

Robertson, Seymour and Thomas [47] proved that G is linklessly embeddable in 3-space if and only if G does not have any graph in the Petersen family as a minor. By the Petersen family we mean the graphs that can be obtained from K 6 by a series of YΔ and ΔY operations. See Fig. 1 for drawings of these graphs on the projective plane; note that the graph in Fig. 1(c) cannot be embedded in the projective plane. In the sequel, we will refer to this graph as \(K_{4,4}^{-}\). In the same paper [47] it is shown that a graph is linklessly embeddable in \(\mbox {{$\mathbb {R}$}}^{3}\) if and only if it admits a flat embedding Footnote 2 in \(\mbox {{$\mathbb {R}$}}^{3}\), i.e. an embedding such that for every cycle C of G, there exists a closed 2-dimensional disk \(D \subseteq \mbox {{$\mathbb {R}$}}^{3}\) with DG=∂D=C. To refer to such a disk D we speak about a panel for C and write D=D(C). Clearly, every flat embedding is linkless, but the converse is not true. In many ways flat embeddings are nicer to work with, and in this paper we will work with flat rather than linkless embeddings.

Fig. 1
figure 1

Petersen’s family

Linkless embeddings have received a lot of attention in the literature. Besides those working on knot theory, many researchers working in discrete mathematics are also interested in this topic. For example, Lovász and Schrijver [29, 30] proved that two well-known invariants given by Colin de Verdière [57] are closely related to linklessly embeddable graphs. The invariants are based on spectral properties of matrices associated with a graph G.

Flat embeddings in 3-space are a generalization of embeddings in the plane. These two embedding problems share an interesting property. The famous theorem by Whitney which says that every 3-connected planar graph has a unique planar embedding, can be generalized to the flat embedding case, i.e., every flatly embeddable 4-connected graph G has an “essentially unique” flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\), see [47]. Here, “essentially unique” means embeddings up to ambient isotopy, which we will define later. In [28], Lovász asked for a polynomial-time algorithm for the following problem:

figure a

1.2 Our Main Result

The main contribution of this paper is to give a polynomial-time algorithm for the flat and linkless embedding problem. This result gives a positive answer to the question of Lovász [28] mentioned above.

Theorem 1.1

There is an O(n 2)-time algorithm for the Flat and Linkless Embedding problem.

Let us observe that if the output of the algorithm is (1), i.e. a member of Petersen’s family as a minor of G, then we have one of the excluded minors for linklessly embeddable graphs and hence this is a certificate that G has no linkless (nor flat) embedding. As mentioned above, by Robertson and Seymour’s results in [41], we can test whether or not an input graph has one of Petersen’s family graphs as a minor, but if it does not contain any of them, that algorithm does not give the second conclusion, i.e. does not produce a flat or linkless embedding.

In [15], van der Holst gives the first polynomial-time algorithm for deciding whether a given graph has a linkless embedding and computing one, if it exists. In this paper we give a different algorithm for producing flat (and hence linkless) embeddings, which runs in quadratic time. Our algorithm is different from van der Holst’s in several respects:

  1. 1.

    Our algorithm finds a flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\), while the algorithm from [15] finds linkless embeddings that are not necessarily flat.

  2. 2.

    We improve on the time complexity as van der Holst’s algorithm needs at least Ω(n 5) steps whereas ours runs in O(n 2).

  3. 3.

    The algorithm and the proof method in [15] are very algebraic and different from our paper, which is more combinatorial and geometric.

There are many NP-hard problems which can be solved in polynomial time (often even linear time) when considering planar graphs or “nearly” planar graphs. Even for problems that remain NP-hard on planar graphs, we often have efficient approximation algorithms, e.g., Independent Set, TSP, Weighted TSP, Vertex Cover, Domination Set, etc. [2, 13, 24, 27]. We expect that most of these fast algorithms for planar graphs can be generalized to linklessly embeddable graphs as well, using our algorithm in Theorem 1.1 and a flat embedding. In addition, linklessly embeddable graphs have an interesting property for the well-known feedback arc set problem, i.e. the problem to compute in a given digraph G a minimum size set of edges whose removal makes G acyclic. Seymour [50] proved that the minimum size of a feedback arc set in an Eulerian linklessly embeddable digraph (i.e., the underlying undirected graph is linklessly embeddable) is equal to the maximum number of arc-disjoint directed cycles. This result can be compared to the well-known result by Lucchesi and Younger [31], who proved that the same conclusion holds for any directed planar graph. The proof given in [50] implies that, given a flat embedding of a given Eulerian digraph G, there is a polynomial-time algorithm to find the minimum size of a feedback arc set, which gives rise to the maximum number of arc-disjoint directed cycles. Thus by Theorem 1.1, we can find such sets in polynomial time for any Eulerian linklessly embeddable graph.

1.3 Overview of the Flat Embedding Algorithm

At a high level of description, the algorithm for Theorem 1.1 proceeds as follows. First, we iteratively reduce the size of the input graph until it is 4-connected and reaches a graph of bounded tree-width. Then the algorithm solves the problem on this graph of bounded tree-width.

Reduction step

For the reduction step, the algorithm first handles small separations and recursively proceeds to smaller graphs until these are 4-connected. Afterwards, we involve the excluded grid theorem [12, 37, 39, 44]. If the tree-width of G is large enough, then G contains a large grid minor. By combining the results in [41] and [21], if an input graph does not contain a K 6-minor, then, after deleting at most one vertex, we can find a grid minor which is planarly drawn, i.e., up to 3-separations, the grid minor induces a planar embedding. If there is a separation (A,B) of order at most three in this planarly drawn grid, then this gives us a reduction (for details, we refer to Sect. 3). Otherwise, this grid minor induces a 2-cell embedding in the plane (and hence it is a planar subgraph).

A deep theorem in [41] tells us that every vertex “deep inside” this grid minor is irrelevant with respect to all excluded minors in the Petersen family. (A shorter proof of this fact is given in [23].) In addition, we prove that such a vertex v does not affect our flat embedding in 3-space. Hence, we can remove v without affecting flat embeddability of G. The main difficulty here is the proof of the existence of this vertex. Once we have proved that there is an irrelevant vertex, algorithmically such a vertex can be found in linear time. By repeating this step, we eventually obtain a subgraph G′ of G of bounded tree-width such that any flat embedding of G′ can be extended to a flat embedding of G, using the reverse steps of the reduction phase. This concludes the reduction step for the proof of Theorem 1.1.

Bounded tree-width case

This is the second step. Its proof of correctness uses two deep results from [47]. The first one is that any Kuratowski graph, i.e., a subdivision of K 5 or K 3,3, has a unique flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\), where uniqueness means “up to an ambient isotopy”. The second ingredient is that if G is 4-connected and has a flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\), then G has a unique flat embedding. By combining these two results, we get the following strong fact:

Fix a flat embedding of a Kuratowski subgraph K of a 4-connected graph G in \(\mbox {{$\mathbb {R}$}}^{3}\). Then the rest of the graph is uniquely attached to K, if G has a flat embedding.

In general, this fact is not enough to derive a polynomial-time algorithm for constructing flat embeddings. However, if the tree-width of a 4-connected graph is bounded, we can construct a flat embedding in polynomial time using dynamic programming, whenever one exists.

1.4 Basic Definitions

For basic graph theory notions, we refer the reader to the book by Diestel [11], for topological graph theory we refer to the monograph by Mohar and Thomassen [35].

A separation of a graph G is a pair (A,B) of subgraphs of G with AB=G such that there is no edge between AB and BA. The order k of the separation is |V(AB)|. The separation (A,B) is proper if AB≠∅ and BA≠∅. A proper separation of order k is also called a k-separation . If (A,B) is a separation, we denote by A + the graph obtained from A by adding edges joining every pair of nonadjacent vertices in V(AB). We define B + analogously.

A tree-decomposition of a graph G is a pair (T,B), where T is a tree and B is a family {B t tV(T)} of vertex sets B t V(G), such that the following two properties hold:

  1. 1.

    tV(T) B t =V(G), and every edge of G has both ends in some B t .

  2. 2.

    If t,t′,t″∈V(T) and t′ lies on the path in T from t to t″, then B t B tB t.

The width of a tree-decomposition (T,B) is max{|B t |:tV(T)}−1. The tree-width of G is defined as the minimum width taken over all tree-decompositions of G. Let (T,B) be a tree-decomposition of a graph G. By fixing a root r of T we give T an orientation. For tV(T) we define T t to be the subtree of T rooted at t, i.e., the subtree of T induced by the set of nodes sV(T) such that the unique path from r to s contains t. We define \(B(T_{t}):= \bigcup_{s\in V(T_{t})} B_{s}\).

One of the most important results about graphs of large tree-width is the existence of a large grid minor or, equivalently, a large wall. Let us recall that an (a×b)-wall is a graph which is isomorphic to a subdivision of the following graph W (a,b). We start with vertex set V={(i,j)∣1≤ia, 1≤jb} and make two vertices (i,j) and (i′,j′) adjacent if one of the following possibilities holds: (1) i′=i and j′∈{j−1,j+1} or (2) j′=j and i′=i+(−1)i+j. Some vertices of the so obtained graph may be of degree 1. We remove them to obtain a 2-connected graph W (a,b).

It is easy to see that if a graph G contains an (a×b)-wall as a subgraph, then it has an \((\lfloor\frac{1}{2}a\rfloor\times b)\)-grid minor, and conversely, if G has an (a×b)-grid minor, then it contains an (a×b)-wall. Let us recall that the (a×b)-grid is the Cartesian product of paths, P a  □ P b . An (8×5)-wall is shown in Fig. 2. We refer to an (r×r)-wall as a wall of height r . In this paper we use the term r-wall to denote the (2r×r)-wall.

Fig. 2
figure 2

An (8×5)-wall and its perimeter

Theorem 1.2

There is a function f:ℕ→ℕ such that if a graph G has tree-width at least f(r), then G contains an r-wall.

The best known upper bound for f(r) is given in [12, 37, 44]. It shows that one can take \(f(r) = 20^{2r^{5}}\). The best known lower bound on possible values of f(r) is Θ(r 2logr), see [44].

1.5 Computational Complexity

Concerning the time complexity of our algorithms, we assume a random-access machine (RAM) model with unit cost for some basic operations. This model of computation was introduced by Cook and Reckhow [9]. It is known as the unit-cost RAM where operations on integers, whose value is O(n) (and hence also integers of value O(n k) for any fixed k), need only constant time; here n is the size of the input. The same model of computation is used in most other embedding algorithms, for example in known linear-time planarity testing algorithms [14].

An important issue is how to represent a spatial embedding of a graph. It turns out that flat embeddings can be represented by integer coordinates in \(\mbox {{$\mathbb {R}$}}^{3}\), where each coordinate is bounded by a polynomial in n. Although there are some (elementary) geometric and algebraic details to be taken care of, we shall not dwell too much in this direction. Instead, we refer to the section on graph drawing in [26].

Concerning the input size, it is proportional to n=|G|, the number of vertices of the input graph. Namely, we first test for the presence of K 6 as a minor. It is known [32] that every graph of order n with at least 4n edges contains K 6 as a minor. So we may assume that the number of edges is ∥G∥=O(n), and thus the input size is also O(n).

2 Flatly and Linklessly Embeddable Graphs

In this section we recall some results about flatly embeddable graphs used later on.

2.1 Construction of Flat Embeddings

Recall that a piecewise linear embedding of a graph in \(\mbox {{$\mathbb {R}$}}^{3}\) is flat if every cycle of the graph bounds a 2-dimensional disk disjoint from the rest of the graph. If C,C′ are disjoint simple closed curves in \(\mbox {{$\mathbb {R}$}}^{3}\), then their linking number is the number of times (modulo 2) that C crosses C′ in a regular projection of CC′ onto some hyperplane. It is easy to see that the linking number (modulo 2) is the same for every such projection. The proof of the following result is easy and the details are left to the reader.

Lemma 2.1

Let G be a graph, and σ be an embedding of G in \(\mbox {{$\mathbb {R}$}}^{3}\). Let C 1,C 2 be disjoint cycles in G, and let P be a path in G that is disjoint from C 1C 2, except that its end vertices are in V(C 1). Let \(C'_{1},C''_{1}\) be the two cycles in C 1P with \(C'_{1} \cap C''_{1}=P\). If the linking number of C 1,C 2 is nonzero, then also one of the linking numbers of \(C'_{1},C_{2}\) or \(C''_{1} ,C_{2}\) is nonzero.

Let v be a vertex of degree 3 in a graph G, with its three neighbors v 1,v 2,v 3. Let H be a graph obtained from Gv by adding three new edges v 1 v 2,v 2 v 3,v 3 v 1. We say that H is obtained from G by a YΔ operation (at v), and G is obtained from H by a ΔY operation (at v 1,v 2,v 3). If G′ can be obtained from G by a series of YΔ or ΔY changes, we say that G and G′ are YΔ-equivalent . The Petersen family is the set of the seven graphs (up to isomorphism) that are YΔ-equivalent to K 6. One of these is the Petersen graph; see Fig. 1.

The following result was proved in [47].

Theorem 2.2

Let H be a graph obtained from a graph G by a YΔ operation. Then G has a flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\) if and only if H has one.

For the purpose of this paper, we need to construct a flat embedding of G from a flat embedding of H. The recipe is easy. The cycle C=v 1 v 2 v 3 in H bounds a disk in \(\mbox {{$\mathbb {R}$}}^{3}\) that is otherwise disjoint from G. All we have to do is to embed the vertex v and the edges vv 1,vv 2,vv 3 into this disk. The proof that this yields a flat embedding is given in [47, Theorem (4.4)].

It is easy to see that vertices of degree one can be deleted and vertices of degree two can be suppressed without affecting linkless or flat embeddability. Similarly, possible parallel edges or loops arising by these reductions can be eliminated. Thus it follows from Theorem 2.2 that we may assume that each vertex has degree at least 4. Furthermore, concerning vertices of degree 4, we have the following.

Lemma 2.3

Suppose that a graph G contains an edge uv, where deg G (u)=4 and deg G (v)=5. Suppose, moreover, that N(u)=(N(v)∪{v})∖{u,a} for some vertex a in N(v), so there is a separation (A,B) of order four such that BA consists of u and v only. Then G has a flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\) if and only if for some (and hence for every) vertex bN(u)∖{v}, the graph Gobtained from G by contracting the edge ub has a flat embedding.

Proof

It is clear that if G has a flat embedding, then also each minor G′ has one. Conversely, suppose that G′ has a flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\). Let b 1,b 2 be the vertices in (N G (u)∩N G (v))∖{b} (cf. Fig. 3) and consider the cycle C=bb 1 vb 2 b in G′. Let D=D(C) be the panel disk for C in G′. If we put the vertex u and the edges from u to V(C) into this disk, we obtain a flat embedding of G. For details, cf. [47, Theorem (5.2)].

Fig. 3
figure 3

The reduction of Lemma 2.3

 □

We now prove the following result, which is important for our application. A proof is given in (4.6) in [47], but for completeness, we shall give a sketch of the proof. Recall from above the definition of the graphs A +,B + for a separation (A,B) of a graph G.

Theorem 2.4

Suppose G has a proper separation (A,B) of order k≤4. Suppose, furthermore, that G contains both A + and B + as minors and that in the case when k=4, AB and BA are both connected. Then G has a flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\) if and only if both A + and B + have one.

Sketch of the proof

Clearly, if G has a flat embedding, then so do its minors A + and B +. Suppose, conversely, that A + and B + have flat embeddings in \(\mbox {{$\mathbb {R}$}}^{3}\). Since the proof is easy when k≤2, we shall assume henceforth that k≥3.

If k=3, let C be the 3-cycle in A + and B + on vertices V(AB). We may transform the flat embedding of A + so that the panel D(C) is in a hyperplane in \(\mbox {{$\mathbb {R}$}}^{3}\) and so that A + lies entirely in the “upper” half-space. If we make the same with B +, where B + lies in the “lower” half-space, we can combine both flat embeddings into a embedding of A +B + by identifying D(C) in both embeddings. The proof that this yields a flat embedding is given in [47, Theorem (4.6)].

Suppose now that k=4. The panels for the four 3-cycles in the complete subgraph K 4 on A +B + in A + can be selected so that their mutual intersection is only at the common edges. Thus, they form a surface of the 2-sphere, which separates \(\mbox {{$\mathbb {R}$}}^{3}\) into two regions. Since AB is connected, we may assume that all edges and vertices of A + lie in the unbounded region. Similarly, we may get a flat embedding of B + such that the graph is disjoint from the exterior of the 2-sphere bounded by the panels of K 4. Again, both embeddings can be combined to obtain an embedding of G, which is flat as proved in [47, Theorem (4.6)]. □

As we show now, the condition in Theorem 2.4, that AB and BA must be connected (when k=4), is automatically satisfied if the graph G does not contain Petersen family minors. More precisely, it suffices to exclude the graphs \(K_{4,4}^{-}\) and \(K_{3,4}^{+}\), where \(K_{4,4}^{-}\) is the graph isomorphic to K 4,4 minus one of the edges, and \(K_{3,4}^{+}\) is obtained from \(K_{4,4}^{-}\) by a YΔ operation at one of the two vertices of degree three. See Fig. 1(c) for an illustration of \(K_{4,4}^{-}\) and Fig. 1(b) for a drawing of \(K_{3,4}^{+}\). Note that \(K_{3,4}^{+}\) can be obtained from K 3,4 by adding a triangle on three vertices in the partition of size 4. This property, proved in the next theorem, will enable us not to impose connectivity on AB and BA when using Theorem 2.4.

Theorem 2.5

Let G be a 4-connected graph and let (A,B) be a proper separation of order 4. Suppose, furthermore, that G contains both A + and B + as a minor. If AB has more than one component, then G contains either \(K_{4,4}^{-}\) or \(K_{3,4}^{+}\) as a minor.

Proof

We shall prove that G has \(K_{4,4}^{-}\) or \(K_{3,4}^{+}\) as a minor, where four vertices of one bipartite class are rooted at V(AB). This means that each of the connected subgraphs of G that are contracted to these four vertices contains one vertex in V(AB). Since AB has at least two components and G is 4-connected, the graph A gives rise to the K 2,4 minor rooted at V(AB). In the rest of the proof we shall show that we can get the rest of the required rooted minor in B.

Let V(AB)={a,b,c,d}. Let B d =B +d. Since G is 4-connected, B d is 3-connected. As shown in [40] (cf. also [16]), there is a rooted K 2,3-minor with vertices a,b,c being the roots for the vertices of degree two in K 2,3, unless B d is a planar graph with a,b,c in the outer face boundary. If we get a rooted K 2,3-minor, then it is easy to get one additional path from d to one of the degree-3 vertices x in this minor by using Menger’s theorem in the 4-connected graph G to get four internally disjoint paths from x to V(AB). All of the above yields a \(K_{4,4}^{-}\) as a minor in G.

It remains to consider the case when B d is planar and a,b,c lie on the same face of the planar embedding. We may assume that the same property holds for other subgraphs, B a ,B b , and B c .

Case 0: AB contains a 3-cycle. Then this cycle and 4 paths from a vertex x in BA to AB give rise to a \(K_{3,4}^{+}\) minor, where the partition with four vertices is formed by {a,b,c,d} and the other partition is formed by x and two components A 1,A 2 in AB.

Case 1: BA is 2-connected. Consider the embedding of B d in the plane and the induced embedding of BA. The outer cycle C of BA can be split into six segments, C a ,C ab ,C b ,C bc ,C c ,C ca , some of them possibly just a vertex, such that C a is the segment determined by the neighbors of a on C, etc.

Subcase 1.1: abE(G). Let P be the path from a to b consisting of C ab and the edges from a and b (respectively) to the ends of C ab . If d has a neighbor in BAP, then there is a \(K_{3,4}^{+}\) minor. Otherwise, d is only adjacent to C ab . In this case d can be added into the face containing all its neighbors, and it is easy to see that we get a \(K_{3,4}^{+}\)-minor in G.

Subcase 1.2: \(ab\not\in E(G)\). By symmetry among a,b,c,d, we may assume now that there are no edges between any of a,b,c,d. In this case we obtain a \(K_{3,4}^{+}\)-minor again.

Case 2: BA has a cutvertex v. Let Q,R be components of BAv. By 4-connectivity, each of Q and R is adjacent to at least three vertices in AB. If these are the same three for Q and R, we get a \(K_{4,4}^{-}\) minor in the same way as at the beginning of this proof. Thus, we may assume that Q is adjacent to a,b,c and R to b,c,d. Since this holds for every cutvertex v, the block structure of BA is path-like, the two endblocks have neighbors in a,b,c and b,c,d (respectively), all intermediate blocks have neighbors b and c, but not a or d. A short proof also shows that B is planar with a,b,d,c on the outer face (in the order as listed). If adE(G) or bcE(G), we get a \(K_{3,4}^{+}\) minor (contract endblocks without their cutvertices to see this). Otherwise, we get a contradiction to A + being the rooted minor in G. □

2.2 Spatial Embeddings of 4-Connected Graphs

The aim of this section is to show that 4-connected linklessly embeddable graphs have essentially unique flat embedding in \(\mbox {{$\mathbb {R}$}}^{3}\). The following results are proved in [47] along with its companion papers [45, 46]. Readers not familiar with these results may wish to consider the survey [48] which contains many of the results needed below. We refer to the graphs K 5, the complete graph on five vertices, and K 3,3, the complete bipartite graph with three vertices per partition, as the Kuratowski graphs. A Kuratowski subgraph of a graph G is a subgraph of G isomorphic to a subdivision of a Kuratowski graph. Let us recall that by a classic result of Kuratowski [25], a graph is planar if and only if it contains no Kuratowski subgraph.

An embedding ϕ of a graph in \(\mbox {{$\mathbb {R}$}}^{3}\) is spherical , if there exists a surface \(\mathcal{S}\subseteq \mbox {{$\mathbb {R}$}}^{3}\) homeomorphic to the 2-sphere such that \(\phi(G) \subseteq\mathcal{S}\).

Lemma 2.6

(Wu [53])

An embedding of a planar graph in \(\mbox {{$\mathbb {R}$}}^{3}\) is flat if and only if it is spherical.

Let ϕ 1,ϕ 2 be embeddings of a graph in \(\mbox {{$\mathbb {R}$}}^{3}\). We say that ϕ 1 and ϕ 2 are ambient isotopic , written as ϕ 1 a.i. ϕ 2, if there exists an orientation-preserving homeomorphism from \(\mbox {{$\mathbb {R}$}}^{3}\) to \(\mbox {{$\mathbb {R}$}}^{3}\) mapping ϕ 1 onto ϕ 2. We will generally not distinguish between two ambient isotopic embeddings and consider them to be equivalent.

An important fact we will be using below is that 4-connected linklessly embeddable graphs have (essentially) a unique flat embedding into 3-space (up to ambient isotopy). Precisely, if ϕ 1,ϕ 2 are flat embeddings of a 4-connected graph in \(\mbox {{$\mathbb {R}$}}^{3}\), then either ϕ 1 a.i. ϕ 2 or ϕ 1 a.i.ϕ 2, where −ϕ 2 is the composition of ϕ 2 and the antipodal map. This is a consequence of the following lemmas.

Lemma 2.7

Any two flat embeddings of a planar graph are ambient isotopic.

In fact, a graph has a unique flat embedding if and only if it is planar. Note that this lemma does not require 4-connectivity.

For the purpose of describing a flat embedding of a planar graph, all we have to do is to embed the graph into a plane in \(\mbox {{$\mathbb {R}$}}^{3}\).

The following is Theorem (7.7) from [47] (see also Theorem (3.4) in [48]).

Lemma 2.8

The graphs K 5 and K 3,3 have exactly two non-ambient isotopic flat embeddings.

Sketch of proof

Let G be a Kuratowski graph and let eE(G). Then Ge is planar and, by Lemma 2.7, has a unique flat embedding ϕ into \(\mbox {{$\mathbb {R}$}}^{3}\). In fact, by Lemma 2.6, \(\phi(G) \subseteq\mathcal{S}\) for a surface \(\mathcal{S}\subseteq \mbox {{$\mathbb {R}$}}^{3}\) homeomorphic to the 2-sphere. Essentially, we have two choices where to draw the edge e, namely inside either of the two components of \(\mbox {{$\mathbb {R}$}}^{3}-\mathcal{S}\), as any two flat embeddings of the edge in the same component yield ambient isotopic embeddings. □

If ϕ is an embedding of a graph G and HG, we write ϕ| H for the restriction of ϕ to H. The next lemma is Theorem (3.5) in [48].

Lemma 2.9

Let ϕ,ϕbe flat embeddings of a graph G which are not ambient isotopic. Then there is a Kuratowski subgraph H of G for which ϕ| H and ϕ′| H are not ambient isotopic.

We now define a neighborhood relation between Kuratowski subgraphs of a graph G. Let H 1,H 2G be Kuratowski subgraphs of G such that \(H_{1}\not=H_{2}\). The subgraphs H 1 and H 2 are 1-adjacent if there exist a path PG and an i∈{1,2} such that P has only its end points in common with H i and such that H 3−i H i P.

H 1 and H 2 are 2-adjacent if there are distinct vertices v 1,…,v 7V(G) and pairwise internally vertex-disjoint paths L i,j , for (i,j)∈{1,…,4}×{5,6,7}∪{(3,4)} linking v i and v j such that H 1=⋃{L i,j ∣(i,j)∈{2,3,4}×{5,6,7}} and H 2=⋃{L i,j ∣(i,j)∈{1,3,4}×{5,6,7}}. See Fig. 4 for an illustration. The path L 3,4, illustrated by the dotted edge in Fig. 4, is not used here but is required to exist. Note that if H 1,H 2 are 2-adjacent, then they are both isomorphic to subdivisions of K 3,3. H 1 and H 2 are adjacent if they are 1- or 2-adjacent. The following result is (3.7) in [48].

Fig. 4
figure 4

2-adjacent Kuratowski subgraphs H 1 and H 2

Lemma 2.10

Let ϕ,ϕbe flat embeddings of G and let H,Hbe adjacent Kuratowski subgraphs of G. If ϕ| H a.i. ϕ′| H then ϕ| H a.i. ϕ′| H.

We say that H and Hcommunicate if there are Kuratowski subgraphs H=H 1,…,H k =H′ of G such that H i and H i+1 are adjacent for all 1≤i<k.

The following result is proved in [45].

Lemma 2.11

If G is 4-connected, then all pairs of Kuratowski subgraphs of G communicate.

In fact, the stronger statement holds: that Kuratowski subgraphs communicate for all graphs which are Kuratowski 4-connected, which essentially says that no two Kuratowski subgraphs can be separated by a separation of order at most 3. For our purposes it suffices to note that any 4-connected graph is also Kuratowski 4-connected. The previous lemmas imply the following result about uniqueness of embeddings for 4-connected graphs. The next result was proved by Robertson et al., see [47, 48].

Lemma 2.12

If ϕ,ϕare flat embeddings of a 4-connected graph G, then ϕ a.i. ϕor ϕ a.i.ϕ′.

Proof

If G is planar then by Lemma 2.7 there is only one flat embedding (up to ambient isotopy). Otherwise, G contains a Kuratowski subgraph K. By Lemma 2.8 either ϕ| K a.i. ϕ′| K or ϕ| K a.i.ϕ′| K . By going from ϕ′ to −ϕ′ if necessary, we can assume that ϕ| K a.i. ϕ′| K . By Lemmas 2.10 and 2.11 ϕ| H a.i. ϕ′| H for all Kuratowski subgraphs HG. Hence, by Lemma 2.9, ϕ a.i. ϕ′. □

For the purpose of this paper this suggests the following algorithm for determining a flat embedding of a graph G. We first choose a Kuratowski subgraph H of G and fix a flat embedding of H. We then choose an adjacent Kuratowski subgraph H′ of G and extend the flat embedding of H to HH′∪L (where L=L 3,4 is the additional path in the case of 2-adjacency, and L=∅ in case of 1-adjacency). This extension is essentially unique. For, suppose there were two non-ambient-isotopic flat embeddings ϕ 1,ϕ 2 of HH′∪L extending the embedding of H. As ϕ 1,ϕ 2 agree (up to ambient isotopy) on H, and H and H′ are adjacent in HH′∪L, Lemma 2.10 implies that they also agree on H′. But then, by Lemma 2.9, as they agree on all Kuratowski subgraphs, ϕ 1,ϕ 2 agree on HH′∪L. Note that Lemma 2.10 and Lemma 2.9 do not require the graph to be 4-connected.

However, if G is 4-connected, then by starting from one Kuratowski subgraph, whose embedding we fix, and iteratively proceeding to adjacent Kuratowski subgraphs, we can embed all Kuratowski subgraphs of G. As shown in the next lemma, each edge of a 4-connected non-planar graph is contained in a Kuratowski subgraph. Thus, the above procedure provides a unique extension to the whole graph. We will employ this idea in Sect. 4.

Lemma 2.13

Each edge in a 4-connected non-planar graph is contained in some Kuratowski subgraph.

Proof

Let K be a Kuratowski subgraph of G, let U be the set of vertices of degree 3 or 4 in K, and let uvE(G)∖E(K). If u,vU, then K+uv contains a Kuratowski subgraph that includes the edge uv, unless K is a subdivision of K 3,3 and u,v are its vertices of degree three in the same bipartite class. Let us call such a pair of vertices a bad pair in K. Suppose now that uU. Since G is 4-connected, there are four internally disjoint paths connecting {u,v} and K, where one of them starts at v and three start at u. The path from v plus one of the paths from u make a path P in G that does not connect a bad pair of vertices in U. Then it is easy to see that K+P contains a Kuratowski subgraph that includes the edge uv.

Suppose now that the edge uv joins a bad pair in every Kuratowski subgraph of G. Then G′=Gu is planar. Since G′ is 3-connected, it has a unique embedding in the plane. Let v and v 1,…,v r (r≥3) be the neighbors of u in G. If G′+uv+uv i or G′+uv i +uv j is non-planar, then the added edges give rise to a Kuratowski subgraph of G in which the edge uv does not connect a bad pair. The same conclusion holds by adding three edges uv,uv i ,uv j . This means that any three vertices v,v i ,v j (1≤i<jr) lie in the same face of G′. As G is non-planar, not all neighbors of u can lie in the same face of G′. But this is possible only if r=3, deg(v)=3 and v 1,v 2,v 3 are neighbors of v. See Fig. 5 for an illustration. In this case, v 1,v 2,v 3 separate the graph G, and this contradiction completes the proof.

Fig. 5
figure 5

Separation of G by {v 1,v 2,v 3}

 □

2.3 Separations of Small Order

Finally, we summarize some purely graph theoretic results concerning separations of order at most four that were proved in [43]. They will be needed later.

Theorem 2.14

Let G be a connected graph and let v 1,v 2,v 3 be vertices in G. Suppose G has no separation (A,B) of order at most two such that {v 1,v 2,v 3}⊆V(B) and AB≠∅. Then either

  1. 1.

    G contains disjoint trees T 1,T 2,T 3 such that T i contains v i for i=1,2,3, and for all 1≤i<j≤3, there is an edge between T i and T j , or

  2. 2.

    G is isomorphic to the star K 1,3 in which v 1,v 2,v 3 are the vertices of degree one.

Theorem 2.15

Let G be a connected graph and v 1,v 2,v 3,v 4 be four vertices in G. Suppose G has no separation (A,B) of order at most three such that {v 1,v 2,v 3,v 4}⊆V(B) and AB≠∅. Then one of the following cases holds:

  1. 1.

    G has disjoint trees T 1,T 2,T 3,T 4 such that T i contains v i for i=1,2,3,4, and for all 1≤i<j≤4, there is an edge between T i and T j .

  2. 2.

    G−{v 1,v 2,v 3,v 4} has at most two vertices, and each of them has degree at least four in G.

  3. 3.

    G can be drawn in a disk such that v 1,v 2,v 3, and v 4 are on the boundary of the disk.

The above results imply the following:

Theorem 2.16

Let G be a graph of minimum degree at least 4. If G has no proper separation (A,B) of order at most three such that G contains both A + and B + as a minor, then G is 4-connected.

Proof

Suppose G has a proper k-separation (A,B) with k≤3. We take such a separation of minimum order. If k≤2, then we can easily find both A + and B + as a minor. Thus, we may assume that k=3. By Theorem 2.14 applied to the graph B with {v 1,v 2,v 3}=V(B)∩V(A), if G does not contain A + as a minor (i.e., excluding case (1) of the theorem), then case (2) holds, so BA consists of a single vertex, which is impossible, because the minimum degree of G is at least 4. Similarly, we argue that G contains B + as a minor. This contradiction to the assumptions proves that G is 4-connected. □

2.4 Societies and Embeddability up to 3-Separations

We use the notion of a “society” introduced by Robertson and Seymour in [40]. Let Ω be a cyclic permutation of the elements of some set; we denote this set by V(Ω). A society is a pair (G,Ω), where G is a graph and Ω is a cyclic permutation with V(Ω)⊆V(G). A cross in a society (G,Ω) is a pair of disjoint paths P 1 and P 2 in G such that each P i has its endpoints in V(Ω) and no other vertex in V(Ω), and further, if we let s i and t i be the ends of P i for i=1,2, then s 1s 2t 1t 2 in the order Ω. A society is cross-free if it has no crosses. A society (G,Ω) is rural if G can be drawn in a disk with V(Ω) drawn on the boundary of the disk in the cyclic order given by Ω. Clearly, a rural society is cross-free. A theorem of Robertson and Seymour [40] says that this is essentially the only obstruction. First we give a definition. A society (G,Ω) is rurally 4-connected if for every separation (A,B) of order at most three with V(Ω)⊆A, the graph B can be drawn in a disk with the vertices of AB drawn on the boundary of the disk. The next result follows from [40].

Theorem 2.17

Every cross-free rurally 4-connected society is rural.

The notion of a rurally 4-connected society involves separations of order at most three. In order to control crosses when we leave out the requirement that the part B in those separations is planar, we introduce another notion of an embedding up to 3-separations. We say that the society (G,Ω) can be embedded into the disk up to 3-separations, if for some k≥0, there are pairwise disjoint sets A 1,…,A k V(G)∖V(Ω) such that

  1. (1)

    for 1≤i,jk with ij, N(A i )∩A j =∅,

  2. (2)

    for 1≤ik, |N(A i )|≤3, and

  3. (3)

    if G′ is the graph obtained from G by deleting A 1∪⋯∪A k and adding new edges joining every pair of distinct vertices in N(A i ), for i=1,…,k, then the induced society (G′,Ω) is rural.

Let us observe the following. Let \({\mathcal{A}}\) ={A 1,…,A k }. Then we can choose \({\mathcal{A}}\) so that, subject to (1)–(3), the following property holds:

  1. (4)

    If |N(A i )|=3, then N(A i ) induces a facial triangle in the rural disk embedding of G′.

To see this, we choose \({\mathcal{A}}\) such that, subject to (1)–(3), the number of non-facial triangles in G′ induced by members of \({\mathcal{A}}\) is minimum. Suppose, without loss of generality, that |N(A 1)|=3 and N(A 1) induces a triangle T 1 in G′, which is not facial. Let D 1V(G′) be such that, for each xV(G), xD 1 if and only if x is contained in the closed disk bounded by T 1. Define \(A'_{1} \subseteq V(G)\) such that, for each xV(G), \(x \in A'_{1}\) if and only if xD 1N(A 1) or xA j for some A j with N(A j )⊆D 1. Let \({\mathcal{A}}' = ({\mathcal{A}}\setminus\{A_{j}\mid N(A_{j}) \subseteq D_{1}\})\cup \{A'_{1}\}\). Then (1)–(3) hold for \({\mathcal{A}}'\), but the number of non-facial triangles in G′ is smaller, a contradiction.

We may also assume the following:

  1. (5)

    If |N(A i )|=j, then there is no separation (A,B) of order at most j−1 in G′ such that N(A i )⊆A and V(Ω)⊆B.

To see this, observe that otherwise, we could have replaced A i by (AB)∪A i .

In the notion of embeddings up to 3-separations, we shall omit the reference to the society Ω if this is clear from the context.

3 Bounding the Tree-Width

In this section we will present the reduction step of the general algorithm for solving the Flat and Linkless Embedding problem as presented in Sect. 5. Let us observe that by Theorem 2.2 and Lemma 2.3 (and remarks preceding Lemma 2.3), we may assume that every vertex in the given graph G has minimum degree at least 4, and no vertex of degree 4 satisfies the assumptions of Lemma 2.3.

Let us define the nails of a wall W to be the vertices of degree three in W. To exclude trivial cases, we shall assume that all walls and subwalls treated in the sequel are large enough. Let us say they have height at least five. As walls are subdivisions of 3-connected graphs, Whitney’s theorem implies that every wall has a unique planar embedding. The perimeter of a wall W, denoted per(W), is the unique cycle of W bounding the face in the planar embedding of W which contains more than 6 nails; see Fig. 2. The bricks of a wall are the faces containing at most 6 nails. For any wall W contained in a graph H, there is a unique component U of Hper(W) containing Wper(W). The compass of W, denoted comp(W), consists of the graph with vertex set V(U)∪V(per(W)) and edge set E(U)∪E(per(W))∪{xyE(G)∣xV(U),yV(per(W))}. A subwall W′ of a wall W is a wall which is a subgraph of W. A subwall of W is proper if it consists of consecutive bricks in consecutive rows of W. The exterior of W′ is WW′. A proper subwall is dividing in H if its compass is disjoint from its exterior. We say that a proper subwall W′ is dividing in a subgraph H′ of H if W′⊆H′ and the compass of W′ in H′ is disjoint from (WW′)∩H′.

A wall is cross-free if its compass does not contain two vertex-disjoint paths having their ends on the perimeter of the wall, where they appear in the interlaced order. Note that if the compass of W has a planar embedding whose infinite face is bounded by the perimeter of W, then W is cross-free.

Seymour [49], Thomassen [51], and others proved that a wall W is cross-free if and only if its compass can be embedded into the plane up to 3-separations such that its perimeter is the outer face boundary (and plays the role of the cyclic order in the society).

It is easy to see that any subwall of a cross-free wall must be both cross-free and dividing. Furthermore, if x and y are two vertices of a cross-free wall W and the graph H contains a path between them which is internally disjoint from W, then either x and y are both on per(W) or some brick contains both of them. If W′,W″ are subwalls of W, the face-distance of W′ and W″ is the minimum number r of bricks B 1,…,B r in W such that W′∪W″∪B 1∪⋯∪B r is connected.

Robertson and Seymour [41] proved:

Theorem 3.1

For every pair of positive integers l and t, there exist integers w(l,t)>w′(l,t)>l+t such that the following holds. Let K be a graph of order t. If the tree-width of a graph H is at least w(l,t), and H has no K-minor, then there is a wall WH of height w′(l,t), and for some subset X of less than \(t \choose2\) vertices of H there are 10 disjoint proper subwalls W′ (of the wall W) of height l, which are disjoint from X and are cross-free and dividing in HX. In addition, these subwalls of height l have face-distance at least t 10 from each other in the wall W.

Explicit bounds for w(l,t) are known. Combining the bound for the grid theorem in [44], the proof of Theorem 3.1 in [41] implies that \(w(l,t) \leq10^{10^{10^{q}}}\), where q=l t. Let us observe that the constants 10 and 10t in Theorem 3.1 can be replaced by any other prescribed constants (as proved in [41]); such a change only affects the integers w(l,t) and w′(l,t).

When we consider the presence of some fixed graph M as a minor in G, a vertex vV(G) is said to be irrelevant (with respect to existence of M minors) if G has an M-minor if and only if Gv has one. The following result was proved in [41] (a shorter proof appears in [23]).

Theorem 3.2

There is a computable function f:ℕ→ℕ satisfying the following. Let t and lf(t) be positive integers, and let H,W,X,K,w(l,t), and w′(l,t) be as in Theorem 3.1. Then there is a proper subwall Wof the wall W of height at least l, which is disjoint from X and is cross-free and dividing in HX, such that every vertex that has face-distance in Wat least l/2 from the perimeter of Wis irrelevant with respect to existence of K-minors.

For the special case when K=K 6 in Theorem 3.2, a stronger version given below is proved in [21]. One strengthening is that in this case we have |X|≤1, so we may assume that X consists of a single vertex. Secondly, a K 6-minor-free graph cannot have three subwalls of a large wall W that are pairwise at face-distance at least two and are dividing but not cross-free in HX. So, we can find a subwall W′ that is dividing and cross-free in HX, and in W′ we can find irrelevant vertices. In the sequel we show how one can find W′ (and hence also irrelevant vertices) in linear time.

Theorem 3.3

There exists an integer f 0 such that for every lf 0, there are integers w(l)>w′(l)>l satisfying the following. Let H be a graph that does not contain a K 6-minor and whose tree-width is at least w(l). Then H contains a wall W of height w′(l) and also contains a vertex xV(H) such that W contains a subwall Wof height l that is cross-free and dividing in Hx. Given the wall W, either a K 6-minor or the vertex x and the subwall Wcan be found in linear time.

We now address how one can obtain the algorithmic result, as claimed at the end of Theorem 3.3. First, it is easy to see that if H has at least 64|H| edges, then one can find a K 6-minor in H in linear time; see [38]. If so, we are done. So, a flatly embeddable graph H has at most 64|H| edges, which we assume henceforth. Second, we apply the algorithmic version of Theorem 3.2. Results in [20], which generalizes the result in [41], yield an algorithm, whose running time is O(∥H∥)=O(|H|), to get the subset X and subwall W′ as in Theorem 3.2. A possible drawback is that |X| could be as many as \(t \choose2\), as in Theorem 3.1. However, when t=6, it is then easy to adapt the algorithm to obtain Theorem 3.3 since, as shown in [21], a graph without K 6 minor can have at most two subwalls at face-distance at least two that are not cross-free.

We now prove the following result concerning flat embeddings. Recall from the beginning of this section that we may assume that a graph G has minimum degree at least 4.

Theorem 3.4

There is a constant f satisfying the following. Let G be a given input graph of minimum degree at least 4, and let W,w(l),w′(l) be as in Theorem 3.3 with lf. Then one of the following holds:

  1. 1.

    G contains K 6, \(K_{4,4}^{-}\) or \(K_{3,4}^{+}\) as a minor.

  2. 2.

    For some vertex xV(G), there is a proper subwall W′ (of the wall W) of height more than l in Gx that is dividing and cross-free in Gx. Moreover, every vertex v which has face-distance at least l/2 from per(W′) in the wall Wis irrelevant with respect to the existence of K-minors, where K is any graph in the Petersen family. Furthermore, for every flat embedding of the graph Gv in \(\mbox {{$\mathbb {R}$}}^{3}\), the embedding of Gv can be extended to a flat embedding of G.

  3. 3.

    There is a reduction as in Lemma 2.3.

  4. 4.

    There is a separation (A,B) of order at most four in G such that xV(AB) and V(AB)∖{x}⊆comp(W) (where the vertex x is as above) and per(W)⊆B. Moreover, G contains both A + and B + as minors. In particular, the separation (A,B) gives rise to a reduction as in Theorem 2.4.

Proof

By Theorem 3.3, if G does not contain K 6 as a minor, then there exists a vertex xV(G) such that there is a proper subwall W′ (of the wall W) of height l in Gx that is cross-free and dividing in Gx. We observe that W′ is not dividing in G, if x exists.

Suppose first that comp(W′) is not cross-free. Let us observe that the pair (comp(W′),per(W′)) is a society in Gx, where we use the cyclic order of vertices on the cycle per(W′). Since comp(W′) is cross-free and dividing in Gx, the society (comp(W′),per(W′)) is rurally 4-connected by Theorem 2.17. We may assume that there is a separation (A′,B′) of order at most three in the society (comp(W′),per(W′)) such that B′ contains all vertices of per(W′), and in addition, A′ does not have an embedding in the plane with V(A′∩B′) in the outer face boundary. (For otherwise, comp(W′) would be cross-free in Gx.)

By Theorem 2.16 and since the minimum degree of G is at least 4, it follows that G is 4-connected.

Therefore, if |V(A′∩B′)|≤2, then adding x to both A′ and B′ would yield a separation of order at most three in the original graph G. Furthermore, if xN(A′−B′), then again, (A′,B′+x) would be a separation of order at most three in G. Thus we may assume that |V(A′∩B′)|=3, and x has a neighbor in A′−B′. We set A=A′+x and B=B′+x. By the 4-connectivity of G and the rural 4-connectivity of the society (comp(W′),per(W′)), it follows that B contains a K 4-minor rooted at V(AB) and that BA is connected. In particular, G contains A + as a minor. If AB is disconnected, then we are done, as there is a K 6, \(K_{4,4}^{-}\) or \(K_{3,4}^{+}\) minor in G by Lemma 2.13. Thus AB is connected. If G also contains B + as a minor, we have the last outcome of the theorem. Therefore, we assume henceforth that B + is not a minor in G.

Since B + is not a minor in G, by Theorem 2.15 and the fact that A cannot be drawn in the plane in such a way that V(AB) appears on the outer face boundary, we conclude that AB consists of exactly two vertices v,v′. If both have degree 5 in G, then the K 4-minor in B rooted at V(AB), together with v,v′, gives rise to a K 6-minor. Thus it follows that the degree of v is 5, the degree of v′ is 4, and vv′∈E(G). But in this case, we can make a reduction as in Lemma 2.3.

Thus we may assume that the comp(W′) in Gx has a 2-cell embedding in a plane with per(W′) in the outer face boundary. The vertex v in the second conclusion of Theorem 3.4 is irrelevant with respect to any minor of the graphs in the Petersen family, as proved in [41] (cf. also [23]).

It remains to prove that for every flat embedding of the graph Gv in \(\mbox {{$\mathbb {R}$}}^{3}\), the embedding of Gv can be extended to a flat embedding G. It follows from Lemma 2.6 that the planar graph comp(W′)−xv has a unique spherical embedding. Thus the unique face F that has all the neighbors of v bounds the panel D=D(F) in the flat embedding of Gv. Then we can embed the vertex v and its incident edges into the disk D. It is easy to see that the resulting embedding of G is still flat. □

Theorem 3.5

Let G,W,f,l,w(l),w′(l) be as in Theorem 3.4. Suppose the wall W is given. Then there is an O(n)-time algorithm, where n=|G|, that returns one of the following outcomes:

  1. 1.

    One of the graphs in the Petersen family as a minor in G.

  2. 2.

    A vertex xV(G) and a proper subwall W′ (of the wall W) of height l in Gx that is dividing in Gx, and is cross-free in Gx. Moreover, we find an irrelevant vertex v as in the conclusion of Theorem 3.4.

  3. 3.

    A reduction as in Lemma 2.3.

  4. 4.

    A separation (A,B) of order at most four in G such that xV(AB) and V(AB)∖{x}⊆comp(W) (where the vertex x is as above) and per(W)⊆B. Moreover, G contains both A + and B + as minors. In particular, the separation (A,B) gives rise to a reduction as in Theorem 2.4.

Proof

We can get the conclusion of Theorem 3.3 in linear time. If we find a K 6-minor, we stop. Otherwise, we obtain x and W′.

By applying the planarity algorithm [4, 14, 52], for any proper subwall W′ in the conclusion of Theorem 3.3, we can test whether or not the compass comp(W′) is planar in Gx with per(W′) in the outer face boundary. Suppose there is a Kuratowski subgraph K′, i.e., either a K 5-subdivision or a K 3,3-subdivision.

We first observe that the pair (comp(W′),per(W′)) is a society in Gx, whose cyclic order is the cyclic permutation of vertices on the cycle the per(W′). If there is a separation (A,B) of order at most three in the society (comp(W′),per(W′)) in Gx such that B contains all the vertices of per(W′) and at least two nodes of the Kuratowski subgraph K′ are contained in AB, then, as in the proof of Theorem 3.4, we can get the third or the fourth conclusion of Theorem 3.5 or we can get a \(K_{4,4}^{-}\) or \(K_{3,4}^{+}\) minor. Suppose such a separation does not exist. This implies that the society (comp(W′),per(W′)) in Gx is not rurally 4-connected. So by Theorem 2.17, the compass comp(W′) is not cross-free, because we can find two vertex-disjoint paths connecting the diagonally opposite corners in the wall W′.

Let us consider the algorithmic aspect of the previous argument. Let us observe that, for each proper subwall W′, once we are given a Kuratowski graph K′, we can test whether or not such a separation (A,B) in the last conclusion of Theorem 3.5 exists in comp(W′) in Gx, in linear time. If such a separation does not exist, by using the standard technique in [41], we can find two vertex-disjoint paths connecting the diagonally opposite corners in the wall W′ in linear time, using the Kuratowski graph K′.

If there are three disjoint proper subwalls that are not cross-free and are pairwise at face-distance at least two, then there is a K 6-minor by the result in [21] (and such a K 6-minor can be found in linear time using the three Kuratowski graphs in these three proper subwalls).

Thus we may assume that there is a proper subwall W′ in the conclusion of Theorem 3.3 such that the comp(W′) in Gx has a 2-cell embedding with per(W′) in the outer face boundary (and such a 2-cell embedding can be found in linear time by the planarity algorithm [4, 14, 52]). In this case, by Theorem 3.5, we can find the vertex in the second conclusion of Theorem 3.4 in linear time. □

4 Flat Embedding when the Tree-Width Is Bounded

In this section we present a quadratic-time algorithm for the Flat and Linkless Embedding problem on graph classes of bounded tree-width. The algorithm is based on various results about flat embeddings presented in Sect. 2.2.

4.1 4-Connected Graphs of Bounded Tree-Width

As a first step, we show how to compute flat embeddings (if they exist) of 4-connected graphs of bounded tree-width.

Lemma 4.1

There is an algorithm which for a given 4-connected graph G either returns a flat embedding of G or finds a minor H of the Petersen family in the graph G, in time f(tw(G))⋅|G|2, for some computable function \(f\mathrel{:} \mbox {{$\mathbb {N}$}}\to \mbox {{$\mathbb {N}$}}\).

Proof

Given G, we first test in linear time f(tw(G))⋅|G| (for instance by using Courcelle’s theorem [10]) if any graph in the Petersen family is a minor of G. If no such minor is found, we compute a flat embedding of G. The lemmas outlined in Sect. 2.2 and the discussion at the end of that section suggest the following algorithm for constructing a flat embedding of a 4-connected graph in \(\mbox {{$\mathbb {R}$}}^{3}\).

  1. 1.

    If G is planar, compute the unique flat embedding of G in \(\mbox {{$\mathbb {R}$}}^{3}\) and stop. Otherwise, choose a Kuratowski subgraph of G and embed it flatly into \(\mbox {{$\mathbb {R}$}}^{3}\).

  2. 2.

    As long as there is a Kuratowski subgraph K of G that is not yet embedded, compute two adjacent Kuratowski subgraphs H,H′ so that H is already embedded but at least one edge of H′ is not yet embedded. At the same time we find the additional path L=L 3,4 from the definition of 2-adjacency, and set L=∅ in case of 1-adjacency of H and H′. As discussed in Sect. 2.2, there is a unique way of extending the embedding of H to an embedding of HH′∪L which can be determined as explained in Sect. 2.2.

First of all, Lemma 2.13 implies that the algorithm returns a flat embedding of the whole graph G. Next, we claim that this algorithm can be implemented to run in time f(tw(G))⋅|G|2, where \(f\mathrel{:}\mbox {{$\mathbb {N}$}}\rightarrow \mbox {{$\mathbb {N}$}}\) is a computable function. Given a 4-connected graph G, first use Bodlaender’s algorithm [3] to compute an optimal tree-decomposition of G in time g(tw(G))⋅|G|, where \(g \mathrel{:} \mbox {{$\mathbb {N}$}}\rightarrow \mbox {{$\mathbb {N}$}}\) is some computable function. Using known planarity algorithms [4, 14, 52], we can find a Kuratowski subgraph K of G required in Step 1 in linear time, or conclude that G is planar, in which case we can easily determine the unique embedding into \(\mbox {{$\mathbb {R}$}}^{3}\). Towards the second step, note that the while loop can take at most ∥G∥ iterations as each iteration embeds at least one new vertex or edge. In each iteration we have to find the two Kuratowski subgraphs H and H′. Since G has bounded tree-width, this can be done in linear time, either by dynamic programming or by realizing that the condition “H,Hare adjacent Kuratowski subgraphs such that H is already embedded and His not” has a straightforward definition in monadic second-order logic (MSO). It follows from a result by Arnborg, Lagergren and Seese [1] that given the MSO-definition, the graphs H,H′ can be computed in time h(tw(G))⋅∥G∥. As for all graphs ∥G∥≤tw(G)⋅|G|, the result follows. □

4.2 Flat Embeddings in Quadratic Time on Graph Classes of Bounded Tree-Width

We are now ready to present the complete quadratic-time algorithm for computing flat embeddings of linklessly embeddable graphs of bounded tree-width.

Lemma 4.2

There is an algorithm which, on input G, solves the Flat and Linkless Embedding problem for G in time f(tw(G))⋅|G|2, for some computable function \(f\mathrel{:} \mbox {{$\mathbb {N}$}}\to \mbox {{$\mathbb {N}$}}\).

Proof

Let G be given. Using Bodlaender’s algorithm [3], we first compute a tree-decomposition of G of width tw(G) in time g(tw(G))⋅|G|. The next step is to test if any graph of the Petersen family is a minor of G. Again, this can be done in time g′(tw(G))⋅|G|. If G contains a Petersen minor, we can conclude that G has no linkless embeddings and return the minor. Otherwise, we perform a preprocessing to break the graph into 4-connected components.

Step 1. We first compute the 2-connected components of G and perform the algorithm recursively on each component. Once flat embeddings of all 2-connected components have been computed, we can combine them to a flat embedding of G in an obvious way.

Step 2. Now suppose there are no 1-separations of G. The next step is to eliminate 2-separations. Using dynamic programming, we can easily find the 3-connected components of G in linear time. Let (A,B) be a separation of order two with {u,v}=V(AB). As there are no 1-separations in G, u and v are connected by a path in A and in B, thus A + and B + are minors in G. Hence, if G is flatly embeddable then so are A + and B +. Their flat embeddings can be computed recursively. We can then combine these embeddings as shown in the proof of Theorem 2.4.

Step 3. Now suppose there are no separations of order ≤2 left in G. The final step is to decompose the graph into 4-connected components. Again, using dynamic programming we can find 4-connected components of G easily. Now let (A,B) be a separation of order three, and let S={u,v,w}=V(AB). As there are no separations of order ≤2 in G, we can apply Theorem 2.14 to each of graphs A and B. If one of A or B (say B) satisfies conclusion (2) of Theorem 2.14, then BA is a single vertex of degree three in G, and we can make a YΔ-reduction at this vertex. We perform the algorithm recursively on the smaller graph and then use Theorem 2.2. Otherwise, A and B satisfy conclusion (1) of Theorem 2.14, which implies that A + and B + are both minors of G. Thus, we can apply Theorem 2.4 to get a flat embedding of G from recursively constructed flat embeddings of A + and B +. Finally, if G is 4-connected, then we get a flat embedding by using Lemma 4.1. □

Using dynamic programming techniques, it is possible to design a linear-time algorithm for computing a flat embedding of a graph of bounded tree-width, or decide correctly that no such embedding exists. The algorithm was sketched in [17] but a full description of the algorithm would be technical and long. As linear time is not needed for the main result of the paper, we refrain from giving the details of the algorithm here.

5 Algorithm

Finally, we are ready to present the complete algorithm.

Flat and Linkless Embedding

Input: A graph G of order n.

Output: Either detect one of Petersen’s family graphs as a minor in G or return a flat (and hence also linkless) embedding of G in \(\mbox {{$\mathbb {R}$}}^{3}\).

Running time: O(n 2).

Description:

Step 1. Initially, we delete all vertices of degree at most 1. Also, if there is a vertex v of degree 2, then we just contract vu, where u is one of the two neighbors of v. Thus we may assume that the minimum degree is at least 3. If there is a vertex v of degree 3, then we perform a YΔ operation at v. We also delete parallel edges or loops if they arise after performing the reductions. We repeat doing this as long as there are some vertices of degree ≤3. Hereafter, we may assume that the minimum degree of the resulting graph G is at least 4. We make the same reductions at any time later if the minimum degree falls below four.

Step 2. Test if the tree-width of the current graph G is small or not, say smaller than some value f, where f comes from Theorem 3.4. This can be done in linear time by the algorithm of Bodlaender [3]. If the tree-width is at least f, then go to Step 3. Otherwise we use the algorithm described in Lemma 4.2 to compute a flat embedding in quadratic time or certify that no such embedding exists by computing a minor of G in the Petersen family.

Step 3. It is easy to see that if the current graph G has at least 26|G| edges, then one can easily find a K 6-minor in linear time (see [38]). So we may assume that the current graph G has at most 26|G| edges.

At this moment, the tree-width of the current graph G is at least f. Use the algorithm of Bodlaender [3] (or the algorithm of Robertson and Seymour [41]) to construct a wall W of height at least w′(l), where w′(l) is as in Theorem 3.3. Perform the algorithm of Theorem 3.5 to find a separation or reduction as in the third conclusion of Theorem 3.5, or an irrelevant vertex v, or a minor of a graph in the Petersen family. If the third outcome occurs, then output the minor. If the second one happens, then we recurse this algorithm to Gv. If the first one happens, then we reduce the size of the current graph G as in the proof of Theorem 3.5. This completes the description of the algorithm. □

The correctness of Steps 2 and 3 follow from Sects. 3 and 4. It is easy to see that degree 1 vertices can be deleted, degree 2 vertices can be contracted, parallel edges and loops can be removed, and YΔ operation can be performed (Theorem 2.2). Thus the correctness of Step 1 follows.

The time complexity of the algorithm can be estimated as follows. All individual reduction steps in the above algorithm can be done in linear time. Applying the recursion results in another factor of n. So in tine O(n 2) we reduce the problem to the case of bounded tree-width graphs. Applying the algorithm once the tree-width is bounded can be done in quadratic time. Thus, the time complexity is O(n 2).