首页 > 代码库 > 六度问题
六度问题
What do Leonard Nimoy, Stana Katic, and RobertDowney Jr. have in common? They all have a Bacon number of 2. The Six Degreesof Kevin Bacon, a game created early in 1994 by three Albright Collegestudents, is a classic problem in graph theory. The object of the game is tofind the shortest path between a given actor and Kevin Bacon, where anintermediary connection can only be made between actors who have appearedtogether in a movie. For example, Stana Katic was inStiletto with KellyHu, who was in The Air I Breathe with Kevin Bacon. While there is onlyone person with Bacon number 0 (Kevin Bacon himself), most individuals involvedin the Hollywood film industry have a Bacon number of 6 or less. As of April28, 2013, the Oracle of Bacon computed that of the actorslisted on the Internet Movie Database, only 329 out of 1,605,485have 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 averageBacon number is 2.994.
<style></style>
But why use Kevin Bacon as the “center” of theHollywood universe? It all started when three college friends, Brian Turtle,Mike Ginelli, and Craig Fass, were snowed in one night watching movies on TV. Footloosewas followed by Quicksilver, with a commercial for a third Kevin Baconmovie coming on between the other two. This impromptu Kevin Bacon marathoncaused 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 everworked with Robert De Niro? This was before the movie Sleepers had beenreleased, so the answer was no. However, De Niro was in The Untouchableswith Kevin Costner, who was in JFK with Bacon. And so the game SixDegrees 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 thatfollowed, they appeared on The Jon Stewart Show and The Howard SternShow to explain the game and eventually released a book, Six Degrees ofKevin <style></style>Bacon. Today, the game is well-known, both for being a fun game to play withfriends, as well as a classic homework problem in many computer scienceclasses.
The Six Degrees of Kevin Bacon game is actually aproblem in graph theory. Every actor is assigned to a vertex, and an edge isadded between two actors if they have appeared together in a movie. Then, theproblem of connecting a given actor to Kevin Bacon in the fewest number ofsteps becomes a traditional graph theory problem – finding the shortest pathbetween two vertices. There are many shortest path algorithms that could beapplied to this problem. For example, Dijkstra’s algorithm, which solves thepositive-weighted shortest-path problem, could be used. After runningDijkstra’s algorithm, we would have the path with lowest cost (i.e. theshortest path) between a given source vertex (the vertex corresponding to KevinBacon for our application) and all other vertices. However, using Dijkstra’salgorithm in this context is excessive. Dijkstra’s algorithm is best suited forsituations where each edge has an associated nonnegative length/weight and thegoal is to find the path that minimizes the total length. For the Six Degreesof Kevin Bacon game, we are only concerned with finding the shortest path interms of the number of connecting movies (edges) used, so each edge can bethought of as having weight 1. Thus, we would like to use the breadth-firstsearch algorithm, which will solve the problem and be more time efficient thanDijkstra’s algorithm.
<style></style>- See more at: http://blogs.ams.org/mathgradblog/2013/11/22/degrees-kevin-bacon/#sthash.ErwClRtr.dpuf
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 , which is the cost of getting from the source vertex to vertex . In our application, the cost after running the BFS algorithm is the Bacon number of the actor associated with vertex . If is the source vertex, we initialize the costs with and for all . The algorithm proceeds as follows, with the eyeball starting at the source vertex:
1. If is the vertex that the eyeball is currently on, then, for all that are adjacent to , we set if .
2. Move the eyeball to another vertex (which has not already been visited by the eyeball) such that . If that is not possible, we move to a that satisfies . 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!
- See more at: http://blogs.ams.org/mathgradblog/2013/11/22/degrees-kevin-bacon/#sthash.ErwClRtr.dpufWhat 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 , which is the cost of getting from the source vertex to vertex . In our application, the cost after running the BFS algorithm is the Bacon number of the actor associated with vertex . If is the source vertex, we initialize the costs with and for all . The algorithm proceeds as follows, with the eyeball starting at the source vertex:
1. If is the vertex that the eyeball is currently on, then, for all that are adjacent to , we set if .
2. Move the eyeball to another vertex (which has not already been visited by the eyeball) such that . If that is not possible, we move to a that satisfies . 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!
- See more at: http://blogs.ams.org/mathgradblog/2013/11/22/degrees-kevin-bacon/#sthash.ErwClRtr.dpuf六度问题