Understanding the Breadth-First Search Algorithm

The breadth-first search (BFS) algorithm is a traversing algorithm where you start at a selected node (the source or starting node) and traverse the graph layer-wise, exploring the neighboring nodes (nodes that are directly connected to the source node). You then move towards the neighboring nodes in the next level.

In this chapter, you will learn about BFS while developing LinkedIn's connection feature. You will learn how second-degree connections can be computed by using the BFS algorithm.

In this chapter, we will cover the following topics:

  • Understanding the LinkedIn connection feature
  • Graph data structure
  • Queue data structure
  • The BFS algorithm
  • DFS versus BFS

Get Hands-On Artificial Intelligence for Search now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.