This repository contains implementations for analyzing graph traversal algorithms (BFS and DFS) on social network data.
- Clone this repository
- Navigate to the repository directory
- Generate the test datasets:
python network_generator.py
This creates a data/ directory with social network datasets of various sizes (100, 500, 1000 users).
The assignment asks you to run three different commands:
python graph_traversal.py --test-bfsTests your breadth-first search implementation on a 100-user network, finding paths between random user pairs.
python graph_traversal.py --test-dfsTests your depth-first search implementation on a 100-user network, exploring reachable users from random starting points.
python graph_traversal.py --benchmarkCompares BFS and DFS performance across networks of size 100, 500, and 1000 users.
.
├── README.md # This file
├── network_generator.py # Generates test datasets
├── graph_traversal.py # BFS and DFS implementations and testing utilities
└── data/ # Generated test datasets
├── network_100.json
├── network_500.json
└── network_1000.json
- Located in
graph_traversal.pyunder PART 1 - Should use a queue to explore neighbors level by level
- Returns shortest path from start to target as a list
- Use
collections.dequefor efficient queue operations
- Located in
graph_traversal.pyunder PART 2 - Should use recursion or a stack to explore deeply before backtracking
- Returns set of all reachable users from start
- Track visited nodes to avoid infinite loops