Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- vector<int> grph[10000];
- int node, edge;
- int level[10000];
- int visited[10000];
- int BFS(int source, int destination){
- visited[source] = 1;
- level[source] = 0;
- queue<int> q;
- q.push(source);
- while(!q.empty()){
- int x = q.front();
- q.pop();
- for(int i = 0; i < grph[x].size(); i++){
- int y = grph[x][i];
- if(visited[y] == 0){
- visited[y] = 1;
- if(level[y] == 0){
- level[y] = level[x] + 1;
- q.push(y);
- }
- }
- }
- }
- return level[destination];
- }
- int main(){
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement