The graph searches Breadth First Search (BFS) and Depth First Search (DFS) and the spanning trees constructed by them are some of the most basic concepts in algorithmic graph theory. BFS trees are first-in trees, i.e., every vertex is connected to its first visited neighbor. DFS trees are last-in trees, i.e., every vertex is connected to the last visited neighbor before it. The problem whether a given spanning tree can be the first-in tree or last-in tree of a graph search ordering was introduced in the 1980s and has been studied for several graph searches and graph classes. Here, we consider the problem of deciding whether a given spanning tree of a bipartite graph can be a first-in tree or a last-in tree of the Lexicographic Breadth First Search (LBFS), a special variant of BFS that is commonly used in graph algorithms. We show that the recognition of both first-in trees and last-in trees of LBFS is NP-hard even if the start vertex of the search ordering is fixed and the height of the tree is four. We prove that the bound on the height is tight (unless P=NP) by showing that for all spanning trees of bipartite graphs with height smaller than four we can solve both search tree recognition problems of LBFS in polynomial time. Finally, we give a linear-time algorithm that solves both problems for chordal bipartite graphs and fixed start vertices.
Read full abstract