Recognizing Graph Search Trees

Graph searches and the corresponding search trees can exhibit important structural properties and are used in various graph algorithms. The problem of deciding whether a given spanning tree of a graph is a search tree of a particular search on this graph was introduced by Hagerup and Nowak in 1985, and independently by Korach and Ostfeld in 1989 where the authors showed that this problem is efficiently solvable for DFS trees. A linear time algorithm for BFS trees was obtained by Manber in 1990. In this paper we prove that the search tree problem is also in P for LDFS, in contrast to LBFS, MCS, and MNS, where we show NP-completeness. We complement our results by providing linear time algorithms for these searches on split graphs.


Introduction
Motivation. Graph searches like Breadth First Search (BFS) and Depth First Search (DFS) are, in the most general sense, mechanisms for systematically visiting all vertices of a graph. Considered as some of the most basic algorithms in computer science, graph searches are taught in many undergraduate courses around the world and represent an elementary component of several graph algorithms, such as finding connected components, testing for bipartiteness, computing shortest paths with respect to the number of edges, or the Edmonds-Karp algorithm for computing the maximum flow in a network [12]. Similarly, DFS is the basis for algorithms for finding biconnected components in undirected graphs [18], strongly connected components in directed graphs [25], topological orderings of directed acyclic graphs [26], planarity testing [19], or solving mazes [13].
We focus on connected searches, that is, a graph search or graph traversal that starts at a vertex and explores the graph by visiting a vertex in the neighborhood of the already visited vertices. If no further restriction is given, we call such a search a generic search. The search paradigms of BFS and DFS can be simply characterized by using a queue or a stack as the data structure for the unvisited vertices in the current neighborhood. However, there are more sophisticated searches like Lexicographic Breadth First Search (LBFS) [23] and Lexicographic Depth First Search (LDFS) [7]. In this article, we also consider Maximum Cardinality Search (MCS) [27] and Maximum Neighborhood Search (MNS) [7].
Usually, the outcome of a graph search is a search order, i.e., a sequence of the vertices in the order they are visited. There are many known results and algorithms that are based on graph search orders. For instance, a perfect elimination order of a chordal graph can be found by reversing an LBFS order on that graph [23]. Apart from a linear recognition algorithm for chordal graphs, LBFS also yields a greedy coloring algorithm for finding a minimum coloring for this graph class [15]. Furthermore, it is possible to generate characterizing vertex orderings for AT-free graphs using BFS [1].
A structure that is closely related to a graph search is the corresponding search tree. Such trees can be of particular interest, as for instance the tree obtained by a BFS contains the shortest paths from the root r to all other vertices in the graph. The trees generated by DFS can be used for fast planarity testing of graphs [19]. Moreover, if a cocomparability graph has hamiltonian path, then such a path can be found by a combination of various graph searches [5]. First, one can use at most n LBFS runs, where n is the number of vertices, to find a cocomparability ordering [11]. Afterwards, the last visited vertex of an LDFS on this cocomparability ordering is the first vertex of a hamiltonian path. Finally, the search tree of a right most neighbor search on the LDFS ordering is a hamiltonian path.
So far, there is no satisfactory answer as to why graph searching works so well. An interesting example are multi-sweep algorithms, such as finding dominating pairs in connected asteroidal triple-free graphs [8]. One can prove that these algorithms are correct. However, it is not clear why multiple runs of a simple algorithm could give such a strong insight into graph structure. Indeed, there seem to be some hidden structural properties of graph searches, which are waiting for discovery and algorithmic exploitation.
As a step in this direction, we study the problem of whether a given tree can be a search tree of a particular search. For BFS-like searches, one usually connects each vertex v ∈ V to its neighbor which appeared first in the BFS order. Contrary, for DFS-like searches, one connects each vertex v ∈ V to the last neighbor visited before v. However, there is no such obvious definition of a tree for MCS or MNS. Therefore, we define Fand L-trees: Given an ordering, in an F-tree each vertex v is connected to its neighbor which appeared first in the ordering before v, whereas in an L-tree each vertex is connected to its neighbor which appeared last before v. A proper definition will be given in Section 2.3. This motivates the following decision problem:

F-Tree (L-Tree) Recognition Problem
Instance: A connected graph G = (V, E) and a spanning tree T .

Task:
Decide whether there is a graph search of the given type such that T is its F-tree (L-tree) of G.
Related work. Already in 1972, Tarjan [25] gave a complete characterization of DFS trees as so-called palm trees. However, no algorithm that determines if a given spanning tree of a graph G is a DFS tree of G was specified in that work. Using the concept of palm trees, Hopcroft and Tarjan developed a linear time algorithm for testing planarity of a graph [19]. Exploiting properties of DFS and BFS trees, the problem of checking whether a given spanning tree of G can be obtained by a DFS on G was formulated by Hagerup and Novak [17]. A few years later, Korach and Ostfeld gave a linear time algorithm for the proposed problem of recognition of DFS-trees [20]. A similar result for the recognition of BFS-trees was given by Manber in 1990 [21]. A problem that is closely related to the search tree recognition problem is the socalled end-vertex problem, i.e., the problem of determining whether a given vertex v in a graph G can be visited last by some graph search method. As a result of numerous new applications in algorithms, the end-vertex problem has received some attention in recent literature. In particular, the end-vertex of an LBFS on a chordal graph is always simplicial [23]. Furthermore, in a cocomparability graph, the end-vertex of an LBFS is a source/sink in some transitive orientation of its complement [16]. End-vertices are of particular interest for multi-sweep algorithms, as every consecutive search starts at the end vertex of the previous search. Here, LBFS provides a linear time algorithm for finding dominating pairs in connected asteroidal triple-free graphs, where a dominating pair is a pair of vertices such that every path connecting them is a dominating set in the graph [8]. The first vertex x is simply the end-vertex of an arbitrary LBFS and the second vertex y is the end-vertex of an LBFS starting in x. Moreover, one can use five LBFS executions followed by a modified LBFS to recognize interval graphs [9]. Crescenzi et al. [10] have shown that the diameter of huge real world graphs can usually be found with only a few BFS executions.
Surprisingly, the problem of deciding whether a vertex can be an end-vertex of a graph search is hard. In 2010, Corneil, Köhler, and Lanlignel [6] have shown that it is N P-hard to decide whether a vertex can be the end vertex of an LBFS. Later, Charbit, Habib, and Mamcarz generalized this result to BFS, DFS, and LDFS. Furthermore, they extended these results to several graph classes. Recently, Beisegel et al. [2] proved N P-hardness results for MCS and MNS, and they also provided linear time algorithms for this problem on split graphs and unit interval graphs.
Our contribution. Although research initially began with the recognition of search trees, the results on the end-vertex problem are currently more extensive. In the light of the new results on the end-vertex problem, we fill in the gaps in the analysis of the complexity of the search tree recognition problem. In this paper, we extend the tree recognition problem to LBFS, LDFS, MCS, and MNS for For L-trees, respectively, by showing N P-hardness results for most of these searches on general graphs, a polynomial time recognition algorithm for L-trees of LDFS on general graphs, and linear time algorithms for the F-tree and the L-tree problem on split graphs for various searches. Table 1 summarizes the known and some of the new results. This paper is organized as follows: First, we provide the necessary definitions in Section 2. An overview of the considered graph searches is given afterwards. In Section 3 we present a polynomial time algorithm for the L-tree problem of LDFS. Sections 4 and 5 are dedicated to the N P-completeness of the F-tree problem for LBFS, MCS and MNS. In Section 6 we give the linear time algorithms for split graphs. We conclude the paper with some related open problems.

General Notation
All graphs considered in this paper are finite, undirected, simple and connected. Given a graph G = (V, E), we denote by n and m the number of vertices and edges in G, respectively. For a vertex v ∈ V , we denote by N (v) the neighborhood of v, i.e., the set N (v) = {u ∈ V | uv ∈ E}, where an edge between u and v in G is denoted by uv. The closed neighborhood of v is the set N [v] = N (v) ∪ {v}. A clique in a graph G is a set of pairwise adjacent vertices and an independent set in G is a set of pairwise nonadjacent vertices. If the neighborhood of a vertex v in G is a clique, then v is said to be a simplicial vertex. The complement of the graph G is the simple graph G having the same set of vertices as G where for x, y ∈ V , we have that xy is an edge of G if and only if it is not an edge in G. For a graph G = (V, E) and an edge e = uv, where u and v are nonadjacent vertices in G, we define G + e to be a graph with vertex set V and edge set E ∪ {e}.
Given a subset S of vertices in G, we denote by G[S] the subgraph of G induced by S, where V (G[S]) = S and E(G[S]) = {xy ∈ E(G) | x ∈ S, y ∈ S}. By G − S we denote the graph induced by V (G) \ S. If S contains just one element v, we will simply write G − v to denote the graph induced by V (G) \ {v}.
A graph G that contains no induced cycle of length larger than 3 is called chordal. If neither G nor its complement contains an induced cycle of length 5 or more, then G is said to be weakly chordal. A two-pair in a graph is a pair of non-adjacent vertices such that every induced path between the two vertices has exactly two edges. We use the following fact about weakly chordal graphs:  Proof. If v is simplicial then it cannot be part of an induced cycle of G of size ≥ 4. Suppose that v is part of an induced cycle of size ≥ 5 in G. Then there is an edge uw in this cycle, such that vu, vw / ∈ E(G), a contradiction to v being simplicial. Suppose that v has at least n − 2 neighbors in G. Then v has only one neighbor in G and, thus, cannot be part of an induced cycle. Suppose v is part of an induced cycle of size ≥ 5 in G. Then v must be non-adjacent to at least two vertices, a contradiction.
A split graph G is a graph whose vertex set can be divided into sets C and I such that C is a clique in G and I is an independent set in G. It is easy to see, that every split graph is chordal, whereas every chordal graph is also weakly chordal.
An ordering of vertices in G is a bijection σ : V (G) → {1, 2, . . . , n}. For an arbitrary ordering σ of vertices in G, we denote by σ(v) the position of vertex v ∈ V (G). Given two vertices u and v in G we say that u is to the left (resp. to the right) of v if σ(u) < σ(v) (resp. σ(u) > σ(v)) and we denote this by u ≺ σ v (resp. u ≻ σ v).
A tree is an acyclic connected graph. A spanning tree of a graph G is an acyclic connected subgraph of G which contains all vertices of G. A tree together with a distinguished root vertex r is said to be rooted. In such a rooted tree a vertex v is an ancestor of vertex w if v is an element of the unique path from w to the root r. In particular, if v is adjacent to w, it is called the parent of w. Furthermore, a vertex w is called the descendant (child) of v if v is the ancestor (parent) of w. A tree is a caterpillar tree, if and only if it admits a dominating path P , i.e., every vertex is either in P or adjacent to a vertex in P .

Graph Searches
In 1976 Rose, Tarjan and Lueker defined a linear time algorithm (Lex-P) which computes a perfect elimination ordering of a graph if any exists. This algorithm is known as Lexicographic Breadth First Search (LBFS) and yields a linear time recognition algorithm for chordal graphs [23]. LBFS exhibits many interesting structural properties and has been used as a subroutine in many other recognition and optimization algorithms.
Algorithm 1: Lexicographic Breadth First Search Maximum Cardinality Search (MCS) was introduced in 1984 by Tarjan and Yannakakis [27] as a simple alternative to LBFS for recognizing chordal graphs. They noticed that, instead of remembering the order in which previous neighbors of a vertex had appeared, it sufficed to just store the number of previously visited neighbors for each vertex. This observation resulted in an algorithm which has a linear running time and an easy implementation.
Input: Connected graph G = (V, E) and a distinguished vertex s ∈ V Output: A vertex ordering σ begin for i ← 1 to n do pick an unnumbered vertex v with the most numbered neighbors; σ(i) ← v;

Algorithm 2: Maximum Cardinality Search
In [7], Corneil and Krueger defined Lexicographic Depth First Search as a lexicographic analogue to DFS. Since then, it has been used for many applications, most notably to solve the minimum path cover problem on cocomparability graphs [5].
Maximum Neighborhood Search (MNS) was introduced by Corneil and Krueger [7] in 2008 as a generalization of LBFS, LDFS and MCS. Instead of using strings (like LBFS and LDFS) or integers (like MCS) the algorithm uses sets of integers as labels and the maximal labels are those sets which are inclusion maximal. Unlike the labels of LBFS, LDFS and MCS, the labels of MNS are not totally ordered and there can be many different maximal labels. Corneil and Krueger showed that every search ordering of LBFS, LDFS and MCS is also an MNS ordering. This result was generalized in 2009 by Berry et al. [3] who showed that the set of MNS orderings is equal to the set of orderings of Maximum Label Search.
The relationship between the various searches can be found in Figure 1. For instance, observe that any LBFS, LDFS or MCS is also an MNS. However, the opposite does not hold.

The Search Tree Recognition Problem
The definition of the term search tree varies between different paradigms. However, typically, it consists of the vertices of the graph and, given the search order (v 1 , . . . , v n ), for each vertex v i exactly one edge to a v j ∈ N (v i ) with j < i. By specifying to which of the previously visited neighbors a new vertex is adjacent in the tree, we can define different types of graph search trees. For example, in a BFS a vertex is typically adjacent to the leftmost neighbor in the search order, while in DFS a vertex v is adjacent to the rightmost neighbor to the left of v. This motivates the following definition.
Definition 3. Given a search discovery order σ := (v 1 , . . . , v n ) of a given search on a connected graph G = (V, E), we define the first-in tree (or F-tree) to be the tree consisting of the vertex set V and an edge from each vertex to its leftmost neighbor in σ.
The last-in tree (or L-tree) is the tree consisting of the vertex set V and an edge from each vertex v i to its rightmost neighbor v j in σ with j < i.
As explained above, if σ and T are the output of a classical BFS, then T is an F-tree with respect to σ, while for a classical DFS the tree T is an L-tree with respect to σ. Given this definition, we can state the following decision problem.

F-Tree (L-Tree) Recognition Problem
Instance: A connected graph G = (V, E) and a spanning tree T .

Task:
Decide whether there is a graph search of the given type such that T is its F-tree (L-tree) of G.
When comparing the different searches, one can see that graph search trees behave very similarly to the searches themselves, in the sense that, for example, an LBFS tree is also a BFS tree, but not vice versa. Some examples of graph search trees illustrating these relationships can be found in Figure 2 The graph in c) shows a search tree that is an F-tree of MNS, BFS and LBFS that is not an F-tree of MCS. Finally, the graph in d) gives an example of a search tree that is an L-tree for DFS, but not for LDFS.

A Polynomial Algorithm for Lexicographic Depth First Search
As Lexicographic Depth First Search is a special case of DFS, the most natural search tree to be considered here is the L-tree. We give a polynomial-time algorithm (Algorithm 5) which, given a graph G and its spanning tree T , decides whether T is an L-tree of LDFS on G. This is an interesting contrast to the fact that it is N P-complete to decide whether a given vertex is an end-vertex of LDFS, as shown by Charbit et al. [4]. In essence, Algorithm 5 runs an LDFS and at every step checks whether there is still a possible choice of vertex which does not contradict the search tree.
To prove that Algorithm 5 works correctly, we first state a few lemmas about L-trees of DFS.
We can give an analogous result for LDFS, which just considers induced subgraphs of G.
Proof. Let G i be an induced subgraph of G and let T i be the restriction of T to G i . Suppose that T is an L-tree of LDFS on G. We will show that in this case T i is an L-tree of LDFS on G i .
return T is an L-tree of LDFS on G. Algorithm 5: Algorithm which decides whether T is an L-tree of LDFS on G.
Let σ be an LDFS search order of G that results in the search tree T and let σ(1) := r. We run an LDFS on G i by always choosing the vertex with largest label which is leftmost in σ and call the new search order τ . Suppose that the resulting search tree R does not coincide with T i . Let v be the leftmost vertex in τ that does not have the same parent in R as it does in T . Let u be the parent of v in R.
Because v was chosen to be leftmost in τ such that it has a different parent in R than in T , the unique path P from u to r in R is identical to that in T . Therefore, we can see that u must be an ancestor of v in T , due to Lemma 4. Let w be the unique child of u in T that is an ancestor of v; in particular v = w and w ≺ σ v. As v is a child of u in R, we can assume that v ≺ τ w. This implies that at the point where v was chosen, the label of v was strictly larger than that of w; this is a contradiction, as all vertices that have labeled v are on P , due to Lemma 4. Therefore, it is identical to the label v had at the point when w was chosen over v in σ.
Theorem 7. The L-tree recognition problem for LDFS can be solved in polynomial time.
Proof. Algorithm 5 tests for a fixed r ∈ V whether T can be an L-tree for LDFS on G that is rooted in r. Therefore, assuming the Algorithm 5 works correctly and in polynomial time, it is enough to apply it to all vertices in G to decide whether T is, in fact, an L-tree of LDFS. As we begin the search in r we from now on assume that T is rooted in a fixed vertex r.
First suppose that the algorithm returns "T is an L-tree of LDFS on G". In this case, the algorithm has successfully executed an LDFS and it remains to show that the resulting search order has T as its L-tree. This, however, is safeguarded by the fact that at every point at which we have added a vertex v to our search order, the predecessor of v, i.e., its parent in the resulting search tree, is also adjacent to v in T . Now assume that the algorithm returns "T is not an L-tree of LDFS on G". This implies that at some point of the LDFS there is no vertex x of lexicographically largest label, such that the predecessor of x is adjacent to x in T . Let v be such a vertex of lexicographically largest label, whose predecessor is not its parent in T . As v is the first such vertex to appear in the search, the tree R constructed thus far by Algorithm 5 is a subtree of T .
Assume that T is, in fact, an L-tree of G generated by LDFS. Let u be the predecessor assigned to v by the algorithm. Thus, due to Lemma 4, u must be an ancestor of v in T . Let w be the unique child of u in T that is also an ancestor of v and let P be the unique path from v to r in T ; in particular, u, w ∈ V (P ). As a result of Lemma 6, P is an L-tree of LDFS on G[V (P )] since T is an L-tree of LDFS on G.
However, Algorithm 5 and Lemma 4 imply that P cannot be an L-tree of LDFS on G[V (P )]: As we start in r and as P is a path, we must choose all vertices up to u in the order of the path. Due to Lemma 4, the vertices have the same labels as they did when Algorithm 5 halted. Therefore, v has a lexicographically larger label than w. As a result, P and, thus, T cannot be a L-trees of LDFS.

N P-Completeness for Lexicographic Breadth First Search
It was shown in [6] that the LBFS end-vertex problem is N P-complete. In the following we show that the same holds for the tree-recognition problem.
Theorem 8. The F-tree-recognition problem of LBFS is N P-complete on weakly chordal graphs.
We prove Theorem 8 by giving a reduction from 3-SAT. Let I be an instance of 3-SAT. We construct the corresponding graph G(I) and the spanning tree T (I) as follows (for an example see Figure 3): Let X = {x 1 , . . . , x k , x 1 , . . . , x k } be the set of vertices representing the literals of I. The edge set E(X) forms the complement of the matching in which x i is matched to x i for every i ∈ {1, . . . , k}. For each clause C i of I we have a triangle consisting of vertices a i , c i and t i . For every triangle representing a clause C i , the vertex c i is adjacent to each literal of the clause C i .
In addition, we have vertices r, p, q and u. Vertex r is adjacent to every vertex apart from the t i and u, while u is adjacent to all vertices apart from the t i and r. Vertex p has additional edges to each vertex in X and to q, while q is also adjacent to all vertices in X and each of the a i . Altogether, G(I) consists of the vertex set V (G(I)) := X ∪ {r, p, q, u} ∪ C 1 ∪ . . . ∪ C l , where C i represents the vertices of the clause-gadget of C i and the edge set is defined as above.
The corresponding spanning tree T (I) consists of the edges incident to r, an edge between u and p and the edges c i t i for all i ∈ {1, . . . l}; they are denoted as thick lines in Figure 3.
x 3 x 4  Proof. Let A be a satisfying assignment of I. The following valid search order produces T (I) as its search tree: We begin in r and then choose p. Next, we can choose vertices from X according to the assignment A in an arbitrary order, i.e., we choose x i or x i corresponding to whether the variable x i is set to 1 or 0 in A. We are then forced to visit the vertex q, as each remaining vertex of X is not adjacent to one of the visited vertices of X. After choosing the remaining vertices of X we proceed to the vertices of the clause gadgets: As a fulfilling assignment sets at least one literal to 1 in each clause, every c i has a neighbor that appears earlier in the search order than q which is the leftmost neighbor of a i in the search order. Hence, for each clause gadget C i we must choose c i before a i . Therefore, we can choose all vertices c i and then all vertices a i . Finally, we can choose u and then all the t i .
It is easy to see that all edges incident to r belong to the search tree of the constructed order, as well as pu. On the other hand, c i t i must be in the search tree for every i ∈ {1, . . . , l}, as c i was always chosen before a i . Therefore, the search tree of the constructed order coincides with T (I).
We now show the other direction of the proof.
Lemma 10. If I does not admit a satisfying assignment, then T (I) cannot be an F-tree of LBFS on G(I).
Proof. We show that for at least one clause gadget C i the vertex a i is visited before c i , thus making T (I) an infeasible search tree.
To prove this, we analyze the order in which the vertices of X are visited in any feasible LBFS search. It is easy to see that any LBFS must begin in r, as r is the only vertex whose incident edges are all tree edges. Next, we are forced to choose p, as otherwise pu cannot be a tree edge. If q is chosen next, then, as a result, a i must be visited before c i for every i ∈ {1, . . . , l} and T (I) cannot be the resulting search tree. Therefore, a subset of the vertices of X must be chosen before the vertex q.
If a vertex x i is visited, then q receives a larger label than x i , as they otherwise share the same set of neighbors among the visited vertices up to that point (and analogously if x i is visited before q). Thus, q must be chosen between any literal vertex and its negation. The largest subset of X that can be visited before q must, therefore, be an assignment of I. As I is not satisfiable, any such assignment must leave at least one clause unfulfilled. If C i is such a clause, then at the point at which q is chosen, c i does not contain any neighbors among the visited literal vertices. As a result, a i receives a larger label than c i and is visited earlier.
Consequently, in any LBFS there must be a clause C i such that a i is visited before c i and c i t i cannot be in the search tree. This shows that T (I) cannot be a F-tree of an LBFS.

Corollary 11. Let I be an instance of 3-SAT. Then I has a satisfying assignment if and only if T (I) is a possible F-tree of LBFS on G(I).
To conclude the proof of Theorem 8 it remains to show that G(I) is weakly chordal for every 3-SAT instance I.

Lemma 12. For each instance I of 3-SAT, the graph G(I) is weakly chordal.
Proof. We need to show that both G(I) and G(I) do not contain a cycle of length ≥ 5. As all the t i are simplicial, we can disregard them, due to Lemma 2. In the remaining graph, both r and u are adjacent to all vertices apart from each other and can, thus, be deleted, due to Lemma 2.
Let H ′ be the graph resulting from deleting r, u and all the t i ; it suffices to show that H ′ is weakly chordal. In addition, it is easy to see that every non-edge x i x i forms a two-pair in H ′ , i.e., the longest induced path between these two vertices is of length 2. Using Lemma 1, we see that H ′ is weakly chordal if and only if H ′ + x i x i is weakly chordal. Furthermore, if we add the edges x i x i for all i ∈ {1, . . . , k} to H ′ , the vertex p becomes simplicial. Therefore, it remains to show that the graph H which is constructed from H ′ by adding the edges x i x i for all i ∈ {1, . . . , k} and then deleting p is weakly chordal.
It is sufficient to show that H is weakly chordal. To do this, we again apply Lemma 2. We can delete q from H as it is simplicial. In the remaining graph, all the a i are adjacent to all but one vertex and can, thus, also be deleted. The remaining graph is a split graph, as the c i form a clique and the literal vertices form an independent set, and, as a result it is weakly chordal.

N P-Completeness for Maximum Neighborhood Search and Maximum Cardinality Search
As we have done for LBFS, we will show that the F-tree problems for MNS and MCS are N P-complete.
x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 In both boxes only non-edges are displayed by dashed lines. The connection of a vertex with a box means, that the vertex is connected to all vertices in this box. Tree edges are depicted by thick edges.

Theorem 13. The F-tree-recognition problem of MNS and MCS is N P-complete on weakly chordal graphs.
For the proof we construct a polynomial reduction from 3-SAT. Let I be an instance of 3-SAT. We construct the corresponding graph G(I) as follows (see Figure 4 for an example): Let X = {x 1 , . . . , x k , x 1 , . . . , x k } be the set of vertices representing the literals of I. The edge-set E(X) forms the complement of the matching in which x i is matched to x i for every i ∈ {1, . . . , k}. Let C = {c 1 , . . . , c l } be the set of vertices representing the clauses of I. The set C is independent in G(I) and every c i is adjacent to each vertex of X, except those representing the literals of the clause associated with c i for every i ∈ {1, . . . , l}. Additionally, we add the vertices r, p, q, a, b and t. The vertices r, p, q and a are adjacent to all literal vertices and all clause vertices and b is adjacent to all literal vertices. Finally, we add the edges ab, ap, aq, bq, br, bt, pr, qr and qt.
The spanning tree T (I) of G(I) consists of all edges incident to r and the edges pa and bt. Proof. If we take the vertex q before b, we will insert the edge qt to the search tree, which is not an element of T (I). Thus, this is not allowed in a search that generates the F-tree T (I). The neighborhood of b is properly contained in the neighborhood of q. Furthermore, q is adjacent to each clause vertex, while b is adjacent to none of them. Hence, if vertex c i is taken before b, then the label of q will always be greater than the label of b in both MNS and MCS and both searches will take q before b.
Lemma 15. Let σ be an MNS ordering of G(I) that generates the F-tree T (I). Then σ(1) = r, σ(2) = p and σ(i) for 3 ≤ i ≤ k + 2 forms an arbitrary assignment of the variables (not necessarily satisfying).
Proof. Any MNS resulting in the search tree T (I) must start in r, since every other vertex is incident to an edge in G(I) which is not an element of T (I). Since a is adjacent to every neighbor of r in G(I) but only to p in T (I), the search has to choose p as the next vertex. Now the literal vertices and the clause vertices have the unique maximal label, since they were labeled both by r and p and every other vertex was labeled by at most one of these two vertices. Because of Lemma 14 we cannot take a clause vertex. Thus, we have to take a literal vertex. With the same argumentation it follows that we have to take a whole assignment, since the literal vertices of variables whose two literal vertices have not yet been chosen always have the unique maximal label.
Lemma 16. If I has a satisfying assignment A, then T (I) is an F-tree of MCS on G(I) and, therefore, also an F-tree of MNS.
Proof. In the following we give a search order which results in the desired search tree T (I). We start with r and then we take p. By doing this, we insert every edge of T (I) apart from bt to the search tree. Next, we take the literal vertices which correspond to the assignment A in an arbitrary order. As a result, the labels of all literal vertices and of the vertices a, b and q are equal to k + 1. Since A is satisfying, each clause vertex was not labeled by at least one of the chosen literal vertices. Hence, it has a label ≤ k +1 and we can take b as the next vertex and insert the last missing edge of T (I). The remaining vertices can be chosen in any possible order, as they do not influence the search tree. Proof. Assume that T (I) is an MNS F-tree of G(I). By Lemma 15 we have to start with r, then p and, next, the literal vertices that correspond to an arbitrary assignment. Since this assignment cannot be satisfying, there is at least one clause vertex which was labeled by every vertex chosen up till now. In the label of every non-clause vertex at least one chosen vertex is missing. Thus, we have to visit a clause vertex next. This contradicts Lemma 14.

Lemma 18. For every instance I of 3-SAT the graph G(I) is weakly chordal.
Proof. To begin with, we will use Lemma 2 to delete some vertices which cannot be part of a cycle of length ≥ 5 in G(I) or its complement. We can delete t, since it is simplicial. Now the vertices r and a are adjacent to every other vertex and, therefore, we can delete these as well. In the resulting graph we can use the same argumentation to delete q and p. The remaining graph only contains the literal vertices, the clause vertices and b. Since x i and x i form a two-pair for every 1 ≤ i ≤ k, we can add the edges x i x i , due to Lemma 1. The resulting graph is a split graph, where X ∪ {b} forms the clique and C forms the independent set. Thus, it is weakly chordal.

Linear Time Algorithms for Split Graphs
Surprisingly, for split graphs the set of F-trees is the same for the searches BFS, MNS, MCS, and LDFS, even though this does not hold for the respective search orders. We exploit this special structure to derive a linear time algorithm for split graphs. Note that LDFS is considered together with an F-tree.

Theorem 19. A tree T is an F-tree of BFS on a split graph G if and only if it is an F-tree of MNS (MCS, LBFS, LDFS).
Proof. Let G = (V, E) be a split graph and let T be an F-tree for BFS on G, generated by the order τ . Let I = {i 1 , . . . , i ℓ } be the independent set and C = {c 1 , . . . , c k } be the clique of G. We show that there is an MNS ordering σ that generates a search tree that coincides with T .
Suppose τ starts with a clique vertex, without loss of generality c 1 , that is, c 1 is the root of the search tree. Then, all other clique vertices c 2 to c k are in the first layer of the F-tree, and additionally, all independent set vertices which are adjacent to c 1 are in the first layer as well. Without loss of generality, i 1 to i q are adjacent to c 1 . Then i q+1 to i ℓ are in the second layer of the tree T . Furthermore, suppose c 2 to c k are indexed in the order of occurrence in the BFS order. Note that BFS may choose i 1 to i q in arbitrary order before the last clique vertex is chosen. Now, we construct an MNS order σ, such that the F-tree of σ is T . We simply pick c 1 to c k in ascending order, that is, we start with the same root c 1 , followed by the clique vertices in unchanged order. Since all vertices in the clique have the same neighborhood of visited vertices at every step and none of the i x has a larger neighborhood, this does not contradict the MNS search paradigm. Finally, we add the independent set vertices to σ. Here, we have to choose the independent vertices with larger neighborhoods first. As the whole neighborhood of each of these vertices is already chosen, this does not change the edges of the tree, i.e., the first visited neighbor. Since the neighbors of the independent set vertices are visited in the same order as in the BFS, the same F-tree T is generated. Now suppose that τ starts with an independent vertex and, without loss of generality, we label the root of the search tree T by i 1 . Then the neighbors of i 1 , say c 1 to c q are in the first layer of the search tree. All other clique vertices and all independent set vertices which are neighbors of c 1 to c q are in the second layer of the F-tree T . Finally, all remaining independent set vertices are in third layer. Again note that c 1 to c k are assumed to be indexed in the order of occurrence in the BFS order.
Again, a similar order σ, now starting with i 1 , followed by c 1 to c k in order of the indices, and afterwards followed by i 2 to i ℓ , respecting neighborhood inclusions, yields the same tree T and it is an MNS order analogous to the above argumentation.
The proof for the other direction can be achieved in the same way. The proofs for MCS, LBFS, and LDFS also follow the same pattern.
As the F-tree problem can be solved in linear time for BFS [21], this, therefore, also holds for the other searches. In order to fully characterize L-trees on split graphs for all the investigated MNS-type searches, we first need two lemmas about their search orders. The first is a typical 3-point condition given by Corneil and Krueger [7]. The following lemma gives some information about the position of elements of the independent set I in an MNS-ordering of a split graph. We show that, whenever a vertex v of I is to the left of some vertex of the clique C, every vertex of C to the left of v has to be a neighbor of v and all remaining neighbors of v have to be chosen directly after v.
Lemma 22. Let G = (V, E) be a split graph with clique C and independent set I. Let σ = (v 1 , . . . , v n ) be an ordering of V . If σ is an MNS-ordering, then it holds for every pair of vertices v i ∈ I and v j ∈ C with j > i that: Proof. Assume that σ is an MNS-ordering and does not fulfill one of the two conditions, i.e., there is a pair of vertices v i ∈ I and v j ∈ C with j > i such that one of the conditions is not fulfilled.
Suppose there is a vertex v k ∈ C with k < i and v k v i / ∈ E. As v k ≺ σ v i ≺ σ v j and v k v j ∈ E and v k v i / ∈ E, it follows from Lemma 21 that there must be a vertex d such that dv i ∈ E but dv j / ∈ E. Since v i ∈ I and v j ∈ C, such a vertex cannot exist. Hence, we know that the first statement holds. Now, assume that the second condition does not hold and let v i be the σ-leftmost vertex for which it fails. Thus, there is a neighbor c of v i and a non-neighbor b of v i such that v i ≺ σ b ≺ σ c. Let b the first non-neighbor of v i to the right of v i on P . Again, we know, due to Lemma 21 and the choice of b, that there must be a vertex d ≺ σ v i with db ∈ E and dc / ∈ E. Since c ∈ C, d must be an element of I. Then, however, the second statement does not hold for d, since between d and its neighbor b the search has taken the non-neighbor v i . This is a contradiction to the minimality of v i . 2. It holds for every leaf w ∈ L with a neighbor v i in T that wv j / ∈ E(G) for j > i.

It holds for every
Proof. First, we show that the three conditions stated in the theorem are necessary. Assume that T is an L-tree of one of the searches, but not a caterpillar tree. We assume, that the tree is rooted in the starting vertex of the search. If T is not a caterpillar, there exists a vertex v that has two children u and w in T which, in turn, also have two children u ′ and w ′ , respectively. We now show that uw / ∈ E: It is clear that we have to take u and w after v, as T is rooted in the starting vertex of the search. Without loss of generality, we assume that u has been visited first. If u is adjacent to w, then the edge vw cannot be part of the tree. Thus, we know that at least one of u and w has to be in I and that v ∈ C.
We first assume that u ∈ I and w ∈ C and, as a result, u ′ ∈ C. By Lemma 22 it follows that u and u ′ have to be taken before w. Since u ′ w ∈ E, the edge vw cannot be part of the tree.
Let us now assume that u and w are elements of I and u is to the left of w. Then u ′ , w ′ ∈ C and u ′ has to be taken before w by Lemma 22. Since w must be to the left of w ′ , the vertex u ′ has to be a neighbor of w. Thus, the edge vw was not inserted into the tree. Therefore, it follows that such a vertex v cannot exist and the tree must be a caterpillar tree.
For the first statement, it remains to show that each v ∈ C is part of P . Assume, v ∈ C is a leaf and on both sides of the neighbor of v on P there is a vertex of C. Let w be the neighbor of v in the tree and let u be the right neighbor of w in P . Then using the same argumentation as above vu / ∈ E and thus u is an element of I. Furthermore, u must be to the left of v in σ. Since u has at least one further neighbor in T , this neighbor is adjacent to v and to the left of v, due to Lemma 22. Thus, the edge vw cannot be an element of T .
For the second and third conditions we first show that, without loss of generality, the starting vertex of the search can be assumed to be v 1 .
Suppose, that the search begins in v i ∈ P with 1 < i < k and that there are two vertices v l , v j ∈ C with l < i < j; let these be leftmost, respectively, rightmost with this property. Furthermore, we assume, without loss of generality, that v l is visited before v j . Let x be the predecessor of v j on P . If x = v i , we have a contradiction to T being an L-tree, as v l was visited after v i . Therefore, let y be the predecessor of x. Again, suppose that y = v i . The vertex v l must have been visited before x, as otherwise T cannot be an L-tree. Due to Lemma 22, v l must be adjacent to x; this is, again, a contradiction to T being an L-tree. As I is an independent set, either x or y must be in C; this is a contradiction to the choice of v j . As a result, we can assume, without loss of generality, that all vertices of C are to the right of the starting vertex in P . If the starting vertex is an element of I, then we see that it must be equal to v 1 . If the starting vertex is an element of C, then it is possible that exactly one vertex of I is to its left. This vertex must be a leaf in G, as T is an L-tree and we can assume that it is in L, without loss of generality.
If, on the other hand, the start vertex r is not in P , then it must have a neighbor v i ∈ P ∩ C which is the second vertex of the search. Due to the above, we see that all other vertices of C can be assumed to be to the right of v i in P , and, therefore, there is a path P ′ fulfilling all the necessary conditions beginning in r.
Hence, the second statement follows from the definition of L-trees and the third statement follows from Lemma 22.
It remains to show that the three conditions are also sufficient. Suppose that we are given a tree T , consisting of a path P = (v 1 , . . . , v k ) and a set of leaves L, which satisfies all three properties; we then construct MNS, MCS, LDFS and LBFS orderings which generate the L-tree T . We consider the ordering σ = (v 1 , . . . , v k , l 1 , . . . , l r ) with l i ∈ L.
First, we show that all vertices of P can be visited consecutively in that order by all of the investigated searches. If all vertices of P are elements of the clique, then this is obvious, as all of these searches can visit a clique in the beginning of the search in an arbitrary order. Now suppose that σ i = (v 1 , . . . , v i ) is a correct search of one of the given types. We show that v i+1 has maximum label at this point of the search.
If v i+1 is an element of C, it is adjacent to all vertices of C ∩{v 1 , . . . , v i }. Furthermore, there cannot be a vertex w ∈ I ∩ {v 1 , . . . , v i } that is not adjacent to v i+1 , but to some other unvisited vertex, due to condition 3b). This implies that v i+1 has largest label for all these searches.
Suppose that v i+1 is an element of I. Due to condition 3a), we see again that v i+1 is adjacent to all vertices of C ∩ {v 1 , . . . , v i }. As a result of condition 3b), we see that there cannot be any unvisited vertex that is adjacent to a vertex from I ∩ {v 1 , . . . , v i }. This implies that v i+1 has largest label for all these searches.
As soon as the path P has been completely visited, the order in which the remaining vertices of I are chosen does not have any impact on the resulting search tree, as all neighbors of these vertices have already been chosen. Therefore, we can visit these in any arbitrary ordering that adheres to the given search paradigm. Finally, due to condition 2, the tree resulting from this search coincides with T .
The three conditions of Theorem 23 can be checked in linear time. As caterpillar trees are recognizable in linear time, it suffices to define the correct path P . To this end, we have to decide whether one of the endpoints must be a vertex from the independent set. Due to Theorem 23, there can be at most one vertex from the independent set at one of the two ends which is not a leaf in G and this vertex must be the start vertex of the search. If such a vertex is a leaf in G, then we can assume that it is not contained in P .
If P does not begin in a vertex of I, conditions 2) and 3) must be checked for both directions of P . It is easy to decide the second condition by simply checking the indices of the neighbors of vertices in L. To check the third condition, we first place the vertices of C in a separate list according to their ordering in P . Then, we mark the neighbors of v for every vertex v ∈ I ∩ P and check, whether all vertices of C that appear before v in P are neighbors of v. The remaining neighbors of v must follow v in P directly. All of these operations can be done in O(deg(v)), resulting in a combined running time of O(|E|).

Conclusion
We have shown that the F-tree problem is N P-complete for LBFS, MCS and MNS. Furthermore, we have given polynomial time algorithms for the L-tree problem of LDFS and for both the F-tree and the L-tree problems of LBFS, LDFS, MCS and MNS on split graphs. To the best of our knowledge, no hardness results for the L-tree problem were known before. Thus, the question arises whether the L-tree recognition problem is easy in general for every graph search.
For the end-vertex problem, there are polynomial algorithms for some chordal graph classes besides split graphs (cf. [2,4,6]). Can these results be transferred to the treerecognition problem? Up to now, there is no known combination of graph class and search for which the end-vertex problem is easy but the tree-recognition problem is hard.
Moreover, we have considered the search tree recognition problem for labeled, unrooted trees in this paper. As a variant of this problem, one could fix the starting vertex of the search, i.e., the input would be a rooted search tree. As we have already seen in Section 3, if we can solve the problem with a fixed start vertex in polynomial time, we can also solve the general problem efficiently by solving it for every vertex as the starting point of the search. Nevertheless, it could be possible that the problem without fixed starting vertex is easier than the problem with fixed start vertex. That is, maybe it is easy to find a search order with arbitrary root, that generates the tree, but it is N P-hard to find one that uses the given root.
As a second variant, one can also consider the unlabeled problem, i.e., no spanning tree is given, but a tree with a matching number of vertices. Thus, we are looking for a search tree which is isomorphic to the given tree. Obviously, this problem is N P-hard for L-trees of DFS, since it includes the hamiltonian path problem. However, it remains open whether there are searches and graph classes where the unlabeled case is easy or even easier than the labeled one.
In the literature, spanning trees with special properties and corresponding optimization problems are well studied. Examples are the maximum leaf spanning tree problem [14] and distance approximating spanning trees [22]. Are there graph classes where search trees of the investigated graph searches solve or at lead to an approximate solution of such problems?