/CS50AI-degrees

A program that determines how many “degrees of separation” apart two actors are using a breadth-first search algorithm.

Primary LanguagePython

CS50’s Introduction to Artificial Intelligence with Python

Project 0: Search: Degrees

Aim: Write a program that determines how many “degrees of separation” apart two actors are using breadth-first search.

Description: According to the Six Degrees of Kevin Bacon game, anyone in the Hollywood film industry can be connected to Kevin Bacon within six steps, where each step consists of finding a film that two actors both starred in.

In this problem, we’re interested in finding the shortest path between any two actors by choosing a sequence of movies that connects them. For example, the shortest path between Jennifer Lawrence and Tom Hanks is 2: Jennifer Lawrence is connected to Kevin Bacon by both starring in “X-Men: First Class,” and Kevin Bacon is connected to Tom Hanks by both starring in “Apollo 13.”

By using breadth-first search, we can find the shortest path from one actor to another.

See full description here: https://cs50.harvard.edu/ai/2020/projects/0/degrees/

Usage: python degrees.py [directory], where [directory] is "small" or "large". Defaults to "large".

Example: $ python degrees.py large Loading data... Data loaded. Name: Emma Watson Name: Jennifer Lawrence 3 degrees of separation. 1: Emma Watson and Brendan Gleeson starred in Harry Potter and the Order of the Phoenix 2: Brendan Gleeson and Michael Fassbender starred in Trespass Against Us 3: Michael Fassbender and Jennifer Lawrence starred in X-Men: First Class