How Did Google's Bacon Number Calculator Work?

Google Search's Bacon number calculator traced the shortest chain of movie appearances connecting any actor to Kevin Bacon. By treating filmographies as a massive network and searching for the fewest steps between two people, the feature instantly displayed both the actor's Bacon number and the exact movies linking them together.

The Six Degrees of Kevin Bacon as a Graph

The calculator was built around the parlor game "Six Degrees of Kevin Bacon," which assumes that any actor in Hollywood can be linked to Kevin Bacon through a chain of shared movie roles. In computer science, this relationship is modeled as an undirected graph:

  • Nodes (Vertices): Each actor in the database is represented as a node.
  • Edges: A connection is drawn between two actors if they appeared in the same film.

In this model, Kevin Bacon has a Bacon number of \(0\). Anyone who acted in a movie with him has a Bacon number of \(1\). An actor who has never worked with Kevin Bacon directly, but appeared in a movie with someone who has, receives a Bacon number of \(2\), and so on.

Powering the Feature with the Knowledge Graph

When Google introduced the Easter egg in 2012, it relied on its Knowledge Graph rather than standard web page indexing. The Knowledge Graph stored structured information about millions of entities, including actors, films, and cast lists. Because this data was already organized into relationships, Google could query who starred in which movie without scanning unstructured text across the web.

Finding the Shortest Path

To calculate the Bacon number for a specific actor, the system needed to find the shortest path between that actor's node and Kevin Bacon's node. This is typically solved using a Breadth-First Search (BFS) algorithm.

Starting from the queried actor, the algorithm explores all direct co-stars (distance \(d = 1\)), then all co-stars of those co-stars (\(d = 2\)), expanding outward layer by layer until it reaches Kevin Bacon. Because BFS explores nodes in order of their distance from the starting point, the first path it finds to Kevin Bacon is guaranteed to be the shortest possible chain.

Displaying the Connection Chain

Once the shortest path was found, Google Search formatted the result into a clean summary box at the top of the results page. It displayed the final Bacon number alongside each step in the chain, naming the intermediate actors and the specific films they shared. If an actor had no valid path to Kevin Bacon in the database, the calculator simply did not return a number.