Using the BFS Algorithm I'm making the Pathfinder Visualizer
-
A graph is a data structure which consists of a finite set of nodes (or vertices) with a set of edges connecting a pair of nodes (or vertices).
-
BFS and DFS are the most basic of graph algorithms which opens the gateway to learning numerous other algorithms based on graphs.
The thing is that we should be able to find our way through this maze above.
- BFS uses queue data structure
- We have to map out our data structure.
- We have to choose between adjacency matrix or adjacency list.
Adjacency matrix is an n x n array ( what we know as 2D) where the horizontal axis represents the vertices and vertical axis represents the edges. When we look at the adjacency matrix below. If we insert the vertices we listed earlier, you will see that on the first column, you have two 1s, in the second position and in the fifth position.