I am working on something for CS and am having a lot of trouble figuring it all out.
The program I need to do has a concept of "Six Degrees of Separation" or "Six Degrees of Kevin Bacon." The idea is that any actor in any movie can be linked to Kevin Bacon through a series of actors that appeared in a movie together.
For example, Ian McKellen, who played Gandalf in the "Lord of the Rings" trilogy, was in "The DaVinci Code" with Tom Hanks, who was in "Apollo 13" with Kevin Bacon. This is a two movie link 'chain' connecting Ian McKellen and Kevin Bacon. Supposedly all actors can be linked back to Kevin Bacon in no more than six links.
The solution program will read a file whose content is a list of movies and a list of sets of actors that appeared in those movies. You need to find a chain of no more than three links that connect two given names (not only Kevin Bacon). We use three rather than six to keep input files of a reasonable size. Also, the current Facebook research shows that maybe the legend should be amended down to three; see the research link above.
This program will connect the actors/actresses in less than three links.
I have this for my to do and requirements set for myself:
My main program, ThreeDegrees.java, is a Java implementation that:
Prompts the user for the name of an input file.Reads the file contents into a graph data structure.Prints the graph data structure.Prompts the user for two names to try connecting.Performs the search and either will print the shortest chain linking the two names in a chain of maximum length three, or prints a message that reports no chain was found. (See the examples for the text your program should print.)If either the first or second name is the empty string (the user hit enter giving no name), then the program should end.If either name is not found in the graph, then the program should print a message to that effect, and request two new names for the next search.
Here is an example file of movie-actor relationships. (The program will read the file and process search queries):
*The title will always be one word and all names will be two words.
Apollo13 Kevin Bacon Tom Hanks Gary Sinise
HollowMan Elisabeth Shue Kevin Bacon Josh Brolin
AFewGoodMen Tom Cruise Demi Moore Jack Nicholson Kevin Bacon
OneCrazySummer John Cusack Demi Moore
DaVinciCode Tom Hanks Ian McKellen Audrey Tautou
Any and all help would be appreciated. Thanks in advance