Skip to content

Implement Smart Campus Path Finder with BFS, DFS, and UCS algorithms#2

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/add-smart-campus-path-finder
Draft

Implement Smart Campus Path Finder with BFS, DFS, and UCS algorithms#2
Copilot wants to merge 2 commits intomasterfrom
copilot/add-smart-campus-path-finder

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Implements a complete graph-based path-finding system for campus navigation with three search algorithms (BFS, DFS, UCS), performance comparison, and traversal history logging.

Implementation

Graph Structure

  • CampusGraph class using adjacency list (dict of dicts) for weighted bidirectional edges
  • Dynamic add/remove operations for nodes and edges with validation

Search Algorithms

  • BFS: Queue-based (deque), shortest path by edge count
  • DFS: Stack-based with optional depth constraint
  • UCS: Min-heap priority queue (heapq) with optional cost limit

Features

  • Performance timing and node visit counting for all algorithms
  • Persistent history logging to traversal_history.txt with timestamps and user context
  • Interactive menu with 9 operations including sample data loader
  • Comprehensive error handling and input validation

Example Usage

from OEL import CampusGraph, find_and_compare_paths

campus = CampusGraph()
campus.add_location('A')
campus.add_location('B')
campus.add_connection('A', 'B', weight=5)

# Runs all three algorithms with performance comparison
find_and_compare_paths(campus, 'A', 'B', user_name='Student')

Output includes: execution time, traversal order, path found, total cost (UCS), nodes visited, and fastest algorithm identification.

Files Changed

  • OEL.py: Complete implementation (672 lines)
  • .gitignore: Exclude Python cache and runtime artifacts
Original prompt

🏫 Smart Campus Path Finder

Objective:

Build a Python program that helps users find paths between locations in a smart campus.

The system must:

1. Use a graph data structure to represent campus locations (nodes) and paths (edges with weights).

2. Implement BFS, DFS, and UCS (Uniform Cost Search) to find paths between two given locations.

3. Display traversal order, cost, and shortest path for each algorithm.

4. Allow the user to dynamically add or remove locations (nodes) and connections (edges).

5. Save traversal history (user name, date/time, visited nodes, shortest path, total cost) to a text file.

6. Compare BFS, DFS, and UCS using the 'time' library to measure execution time.

7. Display number of nodes visited by each algorithm.

8. Add a constraint (depth for DFS or cost limit for UCS).

9. Include clear print statements and formatted output.

10. Use comments to explain every function, algorithm, and key step for clarity.

🧩 Implementation Hints:

- Use adjacency lists or dictionaries for the graph.

- Store edge weights for UCS.

- Use queues (collections.deque) for BFS, stacks for DFS, and priority queues (heapq) for UCS.

- Create separate functions for each algorithm.

- Compare performance using time.time() before and after each search.

- Write traversal results into a "traversal_history.txt" file.

- Ensure user-friendly input/output interaction for choosing algorithms and paths.

💡 Example:

Locations: A, B, C, D, E

Edges: A-B (2), A-C (4), B-D (3), C-E (1), D-E (5)

User chooses: start = 'A', goal = 'E'

The program should run BFS, DFS, UCS, display results, and compare performance.

👉 Now, Copilot: Write the complete Python code for this project with detailed comments and clean formatting.

write this code in the oel.py file


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: H0NEYP0T-466 <172838121+H0NEYP0T-466@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Python program for smart campus path finding Implement Smart Campus Path Finder with BFS, DFS, and UCS algorithms Nov 13, 2025
Copilot AI requested a review from H0NEYP0T-466 November 13, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants