This project is a graph animation that demonstrates the Breadth-First Search (BFS) algorithm using p5.js. It allows you to generate a random graph, run BFS, and step through the algorithm to visualize how it explores nodes.
To launch the animation, follow these steps:
-
Clone or download this repository to your local machine.
-
Navigate to the project directory.
-
Open the
BFS.htmlfile in a web browser. This file contains the HTML and JavaScript code for the animation. -
Interact with the animation using the provided buttons:
- "Generate Graph": Creates a random graph.
- "Run BFS": Initiates the BFS algorithm.
- "Step BFS": Steps through the BFS algorithm one node at a time.
-
Adjust the number of nodes and edges using the input fields and click "Generate Graph" to create a random graph.
-
Click "Run BFS" to start the BFS algorithm. Nodes will be colored to indicate their state (unexplored, currently exploring, explored).
-
Use the "Step BFS" button to visualize the BFS algorithm step by step.
You can modify the appearance and behavior of the animation by editing the following files:
-
sketch.js: Contains the p5.js sketch code, including graph generation and BFS implementation. -
bfs.js: Contains functions related to running BFS.
- Pranav Dhinakar
This project is licensed under the MIT License - see the LICENSE file for details.