4
$\begingroup$

In "Depth-First Search and Linear Graph Algorithms" Tarjan proposed following theorem as the foundation of depth-first search (rephrase a little bit):

Let $G=(V,E)$ be a connected (undirected) graph and $v\in V$ be a vertex, then there is a directed tree as subgraph of $G$ such that:

  1. $v$ is the root of $G$.
  2. Any edge $(p,q) \in E$ is non-crossing, namely $p$ is an ancestor of $q$, or $q$ is an ancestor of $p$

And there is a "one-word proof": DFS (depth-first search). Moreover, Tarjan proved that all such trees are generated by DFS. My question is, are there theorem that could characterize all trees generated by breadth-first search?

$\endgroup$

2 Answers 2

3
$\begingroup$

BFS trees are a standard notion like DFS trees. See for example Chapter 22 of Introduction to Algorithms, by Cormen, Leiserson, Rivest, Stein (aka. CLRS). Notably the following exercise (emphasis mine):

A depth-first forest classifies the edges of a graph into tree, back, forward, and cross edges. A breadth-first tree can also be used to classify the edges reachable from the source of the search into the same four categories.

a. Prove that in a breadth-first search of an undirected graph, the following properties hold:

  • There are no back edges and no forward edges.
  • For each tree edge $(u,v)$, we have $v.d=u.d+1$.
  • For each cross edge $(u,v)$, we have $v.d=u.d$ or $v.d=u.d+1$.

b. Prove that in a breadth-first search of a directed graph, the following properties hold:

  • There are no forward edges.
  • For each tree edge $(u,v)$, we have $v.d=u.d+1$.
  • For each cross edge $(u,v)$, we have $v.d≤u.d+1$.
  • For each back edge $(u,v)$, we have $0≤v.d≤u.d$.
$\endgroup$
1
  • $\begingroup$ I guess it's not a sufficient condition. Anyway I think that's a correct direction to understand BFS trees. $\endgroup$
    – Peter Wu
    Commented Aug 5 at 1:58
0
$\begingroup$

This is an attempt; please check.

Let $G=(V,E)$ be a connected (undirected) graph and $v\in V$ be a vertex, then consider all subgraphs $T=(V,F)$ of $G$ such that:

  1. For each vertex $w\in V$, its distance to $v$ is the same in $G$ and $T$.

  2. There is a total order $<$ on $V$ such that:

    a. For each vertex $w \in V: v \leq w$.

    b. An edge $\{ w,x \} \in E$ is in $F$ if and only if there is no edge $\{ y,x \} \in E$ with $y < w$.

The trees produced by BFS should be exactly the trees satisfying this condition; the order is a BFS order. A proof should be analogous to a proof of Tarjan's theorem.

$\endgroup$
3
  • $\begingroup$ Here's a possible counterexample in my mind: consider graph with edges $(1,2),(1,3),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)$. With root $1$ the tree $(1,2),(1,3),(2,4),(3,5)$ is not a BFS tree ($4,5$ should have same ancestors). $\endgroup$
    – Peter Wu
    Commented Aug 6 at 1:38
  • $\begingroup$ Thank you. Yes, I do think all BFS visits all children of a node in sequence, without visiting any other nodes in between. So I need to fix this answer. $\endgroup$ Commented Aug 6 at 9:06
  • $\begingroup$ I have added a condition, but I should really do the proof first. I hope someone comes up with a better answer. $\endgroup$ Commented Aug 6 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.