Skip to content

noviaputrin/degrees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 Degrees of Separation

A command-line tool that determines how many "degrees of separation" exist between two actors, based on the movies they’ve co-starred in.

πŸ” Description

This program models the famous Six Degrees of Kevin Bacon game, which posits that any two actors can be connected through six or fewer mutual film roles. Using breadth-first search (BFS), this tool finds the shortest connection path between any two actors via shared movie appearances.

$ 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

πŸ“‚ Datasets

The program supports two datasets: small and large. Each dataset folder includes the following files:

people.csv: Contains actor information id, name, birth movies.csv: Contains movie information id, title, year stars.csv: Maps actors to the movies they starred in person_id, movie_id

Example

If stars.csv contains:

102,104257

Then Kevin Bacon (ID 102) starred in A Few Good Men (ID 104257), which can be confirmed using the corresponding entries in people.csv and movies.csv.

🧠 How It Works

The program constructs a graph where:

  • Nodes represent actors
  • Edges represent co-starring in a film

It performs BFS to explore the shortest path between two actors:

  • Each level of search expands to all co-stars of the current actor
  • Paths are tracked to return the list of actors and movies involved

πŸš€ Getting Started

Prerequisites

  • Python 3.x

Running the Program

$ python degrees.py [dataset]

Example:

$ python degrees.py small

You’ll be prompted to enter two actor names, and the program will return the shortest connection between them.

πŸ“ File Structure

β”œβ”€β”€ degrees.py
β”œβ”€β”€ util.py
β”œβ”€β”€ small/
β”‚   β”œβ”€β”€ people.csv
β”‚   β”œβ”€β”€ movies.csv
β”‚   └── stars.csv
β”œβ”€β”€ large/
β”‚   β”œβ”€β”€ people.csv
β”‚   β”œβ”€β”€ movies.csv
β”‚   └── stars.csv

βœ… Features

  • Accurate actor lookup with name disambiguation
  • Fast search using breadth-first algorithm
  • Scalable to large datasets
  • Modular and easy to read codebase

πŸ§ͺ Example Queries

  • Kevin Bacon β†’ Tom Hanks
  • Emma Watson β†’ Daniel Radcliffe
  • Chris Pratt β†’ Zoe Saldana

About

Program implementation of python Search Algorithm

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages