THe code link:
Find the error in the code
Hey @sr30
In the main function, You’re taking input in the wrong way. you need to input no. of test cases t first and then for each case, you have to input n, m, the m triplets and src. Also, graph has to be made separately for each test case.
Your main function should be like this:
int main()
{
int t;
cin>>t;
for(int j=0;j<t;j++)
{
graph g;
int n, m;
cin >> n >> m;
for(int i=0;i<m;i++)
{
int u,v,d;
cin>>u>>v>>d;
g.addedge(u,v,d);
}
int src;
cin>>src;
g.dijkstra(src);
}
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.