This is a Breadth-First Search (BFS) pathfinding visualizer built using Java Swing. It allows users to interactively select two nodes in a graph and visualize the shortest path between them using the BFS algorithm.
- Interactive GUI using Java Swing.
- Circular custom graph layout with labeled nodes.
- Click to select start and end nodes.
- Visualize the shortest path using BFS.
- Green-colored path indicates the shortest route.
- Yellow node = start, Green node = part of path.
- The program displays a static graph with 13 labeled nodes (A to M) in a circular layout.
- You can click on:
- First node β sets the start (Yellow).
- Second node β sets the end, and the BFS algorithm runs.
- The shortest path from start to end (if one exists) is shown in green (both nodes and connecting edges).
- Click any node again to reset and choose a new path.
BFSVisualizer.javaβ The main class, sets up the JFrame and footer.GraphPanel.javaβ Contains the main visual component, handles drawing, user input, and graph logic.Graph.javaβ Handles graph data, BFS logic, and path reconstruction.Edge.javaβ Defines edges between nodes.Node.javaβ Defines individual graph nodes and their visuals.
- JDK 8 or higher installed
- Java-compatible IDE (like IntelliJ IDEA, Eclipse, or VS Code with Java extensions)
- Save all the classes (
BFSVisualizer.java,GraphPanel.java,Graph.java,Node.java,Edge.java) in the same directory. - Compile the files:
javac *.java