I am trying to do Breadth First Search to find the shortest bath on graph the Weights to all nodes is 6 this is my code :
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
bool vis[1200];
int dist[1200];
vector< int > edges[1200];
int main()
{
    int q ;
    cin>>q;
    while(q--)
    {
        int n,m;
        cin>>n>>m;
        for(int i=0; i<m; i++)
        {
            int u,v;
            cin>>u>>v;
            edges[u].pb(v);
            edges[v].pb(u);
        }
        int s;
        cin>>s;
        queue <int> q;
        q.push(s);
        vis[s]=true;
        while(!q.empty())
        {
            int node=q.front();
            q.pop();
            for(int i=0; i<edges[node].size(); i++)
            {
                if(!vis[edges[node][i]])
                {
                    dist[edges[node][i]]=dist[node]+6;
                    q.push(edges[node][i]);
                }
            }
        }
        for(int i=1;i<=n;i++){
            if(i==s)
                continue;
            if(dist[i]==0)
                cout<<-1<<' ';
            else
                cout<<dist[i]<<' ';
        }
        memset(vis,0,sizeof vis);
        memset(dist,0,sizeof dist);
        for(int i=0;i<1200;i++){
            edges[i].clear();
        }
        cout<<endl;
    }
    return 0;
}
's' is the start node if any node i cant reach then print -1 'q' is the number of queries 'm' is the number of edges 'n' is the number of nodes
 
    