ArticleslgStudy

computer science

Bidirectional search

Bidirectional search is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Bidirectional search rather than just read about it. In short: Bidirectional search is a graph search algorithm that finds a shortest path from an initial vertex to a goal vertex in a directed graph. It runs two simultaneous searches: one forward from the initial state, and one backward from the goal, stopping when the two meet.

Key takeaways

  • Bidirectional search belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Bidirectional search to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Bidirectional search from memory before moving on to harder problems.

Reference excerpt

Bidirectional search is a graph search algorithm that finds a shortest path from an initial vertex to a goal vertex in a directed graph. It runs two simultaneous searches: one forward from the initial state, and one backward from the goal, stopping when the two meet. The reason for this approach is that in many cases it is faster: for instance, in a simplified model of search problem complexity in which both searches expand a tree with branching factor b, and the distance from start to goal is d, each of the two searches has complexity O(bd/2) (in Big O notation), and the sum of these two search times is much less than the O(bd) complexity that would result from a single search from the beginning to the goal. Andrew Goldberg and others explained the correct termination conditions for the bidirectional version of Dijkstra’s Algorithm. As in A* search, bi-directional search can be guided by a heuristic estimate of the remaining distance to the goal (in the forward tree) or from the start (in the backward tree). Ira Pohl was the first one to design and implement a bi-directional heuristic search algorithm. Search trees emanating from the start and goal nodes failed to meet in the middle of the solution space. The BHFFA algorithm of de Champeaux fixed this defect. A solution found by the uni-directional A* algorithm using an admissible heuristic has a shortest path length; the same property holds for the BHFFA2 bidirectional heuristic version described by de Champeaux . BHFFA2 has, among others, more careful termination conditions than BHFFA.

Description A Bidirectional Heuristic Search is a state space search from some state s to another state t, searching from s to t and from t to s simultaneously. It returns a valid list of operators that if applied to s will give us t. While it may seem as though the operators have to be invertible for the reverse search, it is only necessary to be able to find, given any node n, the set of parent nodes of n such that there exists some valid operator from each of the parent nodes to n. This has often been likened to a one-way street in the route-finding domain: it is not necessary to be able to travel down both directions, but it is necessary when standing at the end of the street to determine the beginning of the street as a possible route. Similarly, for those edges that have inverse arcs (i.e. arcs going in both directions) it is not necessary that each direction be of equal cost. The reverse search will always use the inverse cost (i.e. the cost of the arc in the forward direction). More formally, if n is a node with parent p, then k1(p,n)=k2(n,p), defined as being the cost from p to n.

Terminology and notation b the branching factor of a search tree k(n,m) the cost associated with moving from node n to node m g(n) the cost from the root to the node n h(n) the heuristic estimate of the distance between the node n and the goal s the start state t the goal state (sometimes g, not to be confused with the function) d the current search direction. By convention, d is equal to 1 for the forward direction and 2 for the backward direction d′ the opposite search direction (i.e. d′=3−d) TREEd the search tree in direction d. If d=1, the root is s, if d=2, the root is t OPENd the leaves of TREEd (sometimes referred to as FRINGEd). It is from this set that a node is chosen for expansion. In bidirectional search, these are sometimes called the search 'frontiers' or 'wavefronts', referring to how they appear when a search is represented graphically. In this metaphor, a 'collision' occurs when, during the expansion phase, a node from one wavefront is found to have successors in the opposing wavefront. CLOSEDd the non-leaf nodes of TREEd. This set contains the nodes already visited by the search

Approaches for bidirectional heuristic search Bidirectional algorithms can be broadly split into three categories: Front-to-Front, Front-to-Back (or Front-to-End), and Perimeter Search. These differ by the function used to calculate the heuristic.

Front-to-back Front-to-Back algorithms calculate the h value of a node n by using the heuristic estimate between n and the root of the opposite search tree, s or t. Front-to-Back is the most actively researched of the three categories. As of 2004, the current best algorithm (at least in the Fifteen puzzle domain) is the BiMAX-BS*F algorithm.

Front-to-front Front-to-Front algorithms calculate the h value of a node n by using the heuristic estimate between n and some subset of OPENd′. The canonical example is that of the BHFFA (bidirectional heuristic front-to-front algorithm), where the h function is defined as the minimum of all heuristic estimates between the current node and the nodes on the opposing front. Or, formally:

hd(n)=mini{H(n,oi)|oi∈OPENd′} where H(n,o) returns an admissible (i.e. not overestimating) heuristic estimate of the distance between nodes n and o. Front-to-Front suffers from being excessively computationally demanding. Every time a node n is put into the open list, its f=g+h value must be calculated. This involves calculating a heuristic estimate from n to every node in the opposing OPEN set, as described above. The OPEN sets increase in size exponentially for all domains with b > 1.

References

Further reading Russell, Stuart J.; Norvig, Peter (2002). "3.4 Uninformed search strategies". Artificial Intelligence: A Modern Approach (2nd ed.). Prentice Hall..

Worked examples

Example 1 — a first encounter with Bidirectional search

Start with the simplest possible case. Write down what Bidirectional search claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Bidirectional search before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Bidirectional search ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Bidirectional search

In research
Bidirectional search appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Bidirectional search in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Bidirectional search is common in secondary-school and first-year university syllabi. It links to neighbouring topics Graph algorithms, Search algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Bidirectional search outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Bidirectional search” →

How to study Bidirectional search in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Bidirectional search means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Bidirectional search out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Bidirectional search in simple terms?

Bidirectional search is a graph search algorithm that finds a shortest path from an initial vertex to a goal vertex in a directed graph. It runs two simultaneous searches: one forward from the initial state, and one backward from the goal, stopping when the two meet.

Why does Bidirectional search matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Bidirectional search?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Bidirectional search.

Tags

  • Graph algorithms
  • Search algorithms

Keep exploring