I have the database movies (movie_id INT, actor VARCHAR(80)) and i want to answer to this question
’Six degrees of separation’: Given two actor names, determine their ’degree of separation’, defined as 1 follows: Two actors ’A’ and ’B’ are 1-degree away if they played in at least one movie together; they are 2-degrees away if there exists an actor ’C’ who is 1-degree away from each of ’A’ and ’B’; and so on.
Do you have any idea how i can do this ?
Thank you

Recommended Answers

All 3 Replies

This seems to be not so trivial as it looks. You have to find not only some distance between two actors, but the minimum distance. This means that you have to scan all possible paths from actor1 to actor2, including the possibility that they are not connected at all.
I don't know yet the answer, but I found this here thinking about a solution:
http://techportal.ibuildings.com/2009/09/07/graphs-in-the-database-sql-meets-social-networks/

This is rather annoying. I believe that a forum like this one are meant to help people share their knowledge and help each other, in real questions, and not high school (or elementary) exercises.

If this is an elementary exercise, what is the solution? And why do you mind helping them with their homework if you don't mind helping them with their work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.