STEM Interactive Visual Learning Program at TEC-Bridge AI
Setup Graph
BFS Controls
Graph Visualization
Colors: Green = Start, Yellow = Current, Blue = Visited, Orange = Queued
Algorithm Steps
Queue
Conclusion
How to Use
Setup: Click "Sample Graph" or "Random Graph" to create a graph
Start Node: Enter the starting node (e.g., A, B, C) and click "Start BFS"
Step Through: Click "Next Step" to see each step of the BFS execution
Run Through: Click "Run Through" to automatically execute all steps
Observe: Watch nodes change colors and the queue update as BFS progresses
Reset: Click "Reset" to start over with a new search
BFS Concept
Breadth-First Search (BFS) is a graph traversal algorithm that explores nodes level by level, visiting all neighbors before moving deeper.
How it works:
Start with a node and add it to the queue
Mark the current node as visited
Add all unvisited neighbors to the queue
Remove the front node from queue and repeat
Continue until queue is empty
Guarantees shortest path in unweighted graphs
Time Complexity: O(V + E) where V = vertices, E = edges
Use Cases for BFS Algorithm
Social Network Analysis: Finding all friends within N degrees of separation in social networks (Facebook, LinkedIn)
Web Crawling: Systematically exploring websites by visiting all pages at each depth level before going deeper
Peer-to-Peer Networks: Discovering peers in a distributed network by exploring neighbors level by level
GPS Navigation: Finding nearest locations or facilities (hospitals, gas stations) within a certain distance radius
Game AI Pathfinding: Determining shortest path for characters to move through game environments and terrain
Network Broadcasting: Efficiently distributing information to all nodes in a network with minimum hops
Puzzle Solving: Finding the minimum number of moves to solve puzzles like Rubik's cube or 8-puzzle problems
Image Processing: Flood fill algorithm for filling regions with the same color in image editors
Real-World Example: Social Media Friend Recommendations
When you receive a "People You May Know" recommendation on social media platforms, BFS is used to find users who are friends of your friends. The algorithm explores your immediate friend connections (level 1), then their friends (level 2), then their friends (level 3), and so on. This ensures recommendations are based on connection proximity rather than random selection. Each person explored in level order represents a potential connection, allowing the platform to suggest users with the highest likelihood of being known to you. This is more efficient than searching the entire user base randomly.