Graph Theory(Breadth First Search)
Hellllo, guys new article again WOwwwww in this article I will talk about another search way in graph topic, which is DFS. first, let's speak about how it's working?? ok, as you see now in this image Bfs is working by search level by level it searches in the level one first then when it's complete level one it starts a search in the next level and so on. ( notes that Bfs work in an unweighted graph or weighted graph with equal-weighted ) ( notes that Bfs is used to search to the shortest path ) EXAMPLE :( maze solver ) now, we wanna ask a question how can i know the level of the node in implementation? we will write this algorithm by using a queue of pair the first one will be the value of the node and the second one will be the level . Like: vector<int> BFS(int s, vector<vector<int> > & adjList) { vector<int> len(sz(adjList), OO); //oo is define to infinity queue< pair<int, int> > q; q...