Question: (JAVA only) The description for the project and the files needed are below. Basically it needs to create a graph (included class) of the set

(JAVA only) The description for the project and the files needed are below. Basically it needs to create a graph (included class) of the set of movies and their actors, with edges attached from actor to movie. The graph itself is an ArrayList>, with each index being either a movie or actor, and the ints being the movies they are connected to. The strings for each one are separated with split("/") and are stored in a HashMap. Each line starts a new movie. I understand how to do most of the coding, but #15 has me at a loss, mainly because part of the assignment is to have that part run in under a second. The teacher said it is 100% possible to do.

The files are movies.txt for the movies and actors list, and graph.java for linking them together, and neither file should be edited.

https://files.fm/u/mfbrhh7a

1. The vertex set will consist of all people (names) who are featured in the movies (the cast ) and the names of the movies (with the year). The edges will go between the cast members and the movies in the sense that if a person (actor ) is featured in a movie then there is an edge between the two. Obviously therefore, there will not be any edge present between the actors OR between the movies.

2. Each line of the text file (saved in UTF8 format) is to be read as a String with nextLine() and then separated out using the split(/) method. The first one in the separated out array is always the movie name and the rest are all people names.

3. It is recommended that as you read the movies file into memory, you will generate for each line of the file, the vertices and the edges for that line right away. Basically, you will first call addVertex() before calling addEdge() between a pair of previously created vertices.

4. You will use integers 0, 1,2,3,.., etc for labeling the vertices of the movie graph. Now, you need a way to go between these integer labels and the actual movie descriptors. In other words, for every vertex j (integer) you should be able to determine if it corresponds to a movie or a actors name quickly and probably vice versa and then be able to produce the movie name or the actors name. Hash structures are good for this.

5. It is a good idea to find and use a mechanism (some data structure or attributes) to distinguish the two types of vertices in the graph, the movies vs the cast.

6. Do not add any code to the Graph class with regard to movie text file information. The Graph class is a general purpose utility that can used to build a graph for any type of appropriate data. This means that you will create separate Java class file(s) for doing this assignment.

7. Feel free to use as many data structures as needed (subject to your computers memory limits) to make the code time-efficient.

8. The first goal is to build the graph of movies and cast members featured in the movie. And in that process, build auxiliary data structures to answer questions efficiently.

9. You will then build code to answer the following questions (via suitable methods).

10. How many unique movies are there?

11. How many unique cast members are there? You can assume that two people with identical names are the same people which we will agree as a bit of oversimplification.

12. How many edges are there?

13. Given a cast member, print the list of movies in which the cast member is featured in.

14. Write a method public void coCast (int minMovies) that when provided with a threshold minimum number of movies, lists all pairs of cast members that are featured together in at least minMovies along with the titles of such movies. For instance, coCast(5) will produce a list of pairs of cast members which are featured together in at least 5 movies.

15. In particular, run the method for minMovies =13 and produce the listing. It should give you nine pairs of cast members. Your method should not take more than 2 to 3 minutes to run. You must meet the runtime performance.

16. Also find the pair of cast members who have featured in the most number of movies together. Yes, there is only one and produce the movie title along with the names of the two cast members. Of course, if you solved question 15 above, you got this one as well.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!