# The Six Degrees of Kevin Bacon What do Leonard Nimoy, Stana Katic, and Robert Downey Jr. have in common? They all have a Bacon number of 2. The Six Degrees of Kevin Bacon, a game created early in 1994 by three Albright College students, is a classic problem in graph theory. The object of the game is to find the shortest path between a given actor and Kevin Bacon, where an intermediary connection can only be made between actors who have appeared together in a movie. For example, Stana Katic was in Stiletto with Kelly Hu, who was in The Air I Breathe with Kevin Bacon. While there is only one person with Bacon number 0 (Kevin Bacon himself), most individuals involved in the Hollywood film industry have a Bacon number of 6 or less. As of April 28, 2013, the Oracle of Bacon computed that of the actors listed on the Internet Movie Database, only 329 out of 1,605,485 have a Bacon number of 7 or higher:

Bacon Number # of people
0 1
1 2769
2 305215
3 1021901
4 253177
5 20060
6 2033
7 297
8 25
9 7

In fact, using this table, we find that the average Bacon number is 2.994.

But why use Kevin Bacon as the “center” of the Hollywood universe? It all started when three college friends, Brian Turtle, Mike Ginelli, and Craig Fass, were snowed in one night watching movies on TV. Footloose was followed by Quicksilver, with a commercial for a third Kevin Bacon movie coming on between the other two. This impromptu Kevin Bacon marathon caused the three friends to remark on the multitude of movies which included Bacon. It seemed like he was in everything! This prompted the question: Had Bacon ever worked with Robert De Niro? This was before the movie Sleepers had been released, so the answer was no. However, De Niro was in The Untouchables with Kevin Costner, who was in JFK with Bacon. And so the game Six Degrees of Kevin Bacon was born.

Turtle, Ginelli, and Fass wrote a letter to Jon Stewart, explaining the game and how “Kevin Bacon was the center of the entertainment universe.” In the months that followed, they appeared on The Jon Stewart Show and The Howard Stern Show to explain the game and eventually released a book, Six Degrees of Kevin Bacon. Today, the game is well-known, both for being a fun game to play with friends, as well as a classic homework problem in many computer science classes.

The Six Degrees of Kevin Bacon game is actually a problem in graph theory. Every actor is assigned to a vertex, and an edge is added between two actors if they have appeared together in a movie. Then, the problem of connecting a given actor to Kevin Bacon in the fewest number of steps becomes a traditional graph theory problem – finding the shortest path between two vertices. There are many shortest path algorithms that could be applied to this problem. For example, Dijkstra’s algorithm, which solves the positive-weighted shortest-path problem, could be used. After running Dijkstra’s algorithm, we would have the path with lowest cost (i.e. the shortest path) between a given source vertex (the vertex corresponding to Kevin Bacon for our application) and all other vertices. However, using Dijkstra’s algorithm in this context is excessive. Dijkstra’s algorithm is best suited for situations where each edge has an associated nonnegative length/weight and the goal is to find the path that minimizes the total length. For the Six Degrees of Kevin Bacon game, we are only concerned with finding the shortest path in terms of the number of connecting movies (edges) used, so each edge can be thought of as having weight 1. Thus, we would like to use the breadth-first search algorithm, which will solve the problem and be more time efficient than Dijkstra’s algorithm.

The breadth-first search (BFS) algorithm operates by processing vertices in layers: Those closest to the source vertex are evaluated first, and those most distant are evaluated last. The algorithm uses a “roving eyeball” approach, where the eyeball moves from vertex to vertex, starting at the source (Kevin Bacon). Associated with each vertex is a number $D_i$, which is the cost of getting from the source vertex to vertex $i$. In our application, the cost $D_i$ after running the BFS algorithm is the Bacon number of the actor associated with vertex $i$. If $S$ is the source vertex, we initialize the costs with $D_S = 0$ and $D_i = \infty$ for all $i \neq S$. The algorithm proceeds as follows, with the eyeball starting at the source vertex:

1. If $v$ is the vertex that the eyeball is currently on, then, for all $w$ that are adjacent to $v$, we set $D_w = D_v + 1$ if $D_w = \infty$.

2. Move the eyeball to another vertex $u$ (which has not already been visited by the eyeball) such that $D_u \equiv D_v$. If that is not possible, we move to a $u$ that satisfies $D_u = D_v + 1$. If that is not possible, we are done.

The algorithm uses a queue data structure to store intermediate results as the eyeball moves around the graph. When a vertex has its distance lowered (which can only happen once), it is placed in the queue so that the eyeball can visit it in the future. The source vertex is placed in the queue when its distance is initialized to zero.

In the BFS algorithm, there is nothing special about the vertex associated with Kevin Bacon, other than the fact that it is designated as the source vertex and so is where the eyeball starts. We could have just as easily started with a different actor, which would give us a new “center” of the Hollywood universe. But can we do better than Kevin Bacon? According to the Oracle of Bacon, the answer is yes! By comparing the average personality numbers (e.g. for Kevin Bacon we would use the weighted average of all “Bacon Numbers” while for Sean Connery we would use the weighted average of all “Connery Numbers”), actors can be ranked. As of April 28, 2013, Kevin Bacon is the 370th best center, where actors are compared based on their average number. Can you guess who is the best “center” of the Hollywood universe? Head on over the the list of 1000 best centers and find out!

Sources: 1. Kevin Bacon says: