Community Answer

// function for finding minimum no. of edge // using BFS int minEdgeBFS(vector <int> edges[], int u,                               int v, int n) {     // visited[n] for keeping track of visited     // node in BFS     vector<bool> visited(n, 0);        // Initialize distances as 0     vector<int> distance(n, 0);        // queue to do BFS.     queue <int> Q;     distance[u] = 0;        Q.push(u);     visited[u] = true;     while (!Q.empty())     {         int x = Q.front();         Q.pop();            for (int i=0; i<edges[x].size(); i++)         {             if (visited[edges[x][i]])                 continue;                // update distance for i             distance[edges[x][i]] = distance[x] + 1;   ... See the full answer