some error in prims algo that is not giving the correct answer
Mst using prims algo
Hey @akshatkaush
Graph is undirected so change your add edge function accordingly
and in While loop of bfs you are considering 1st element as weigth and 2nd element as node
but you are pushing in reverse order in add edge .
Also you only have to relax the neighbors of current node ,so you should bot have used two loops here
for(auto it:l)
{
for(auto k:it.second)
{if(vis[k.first]==0)
q.push(make_pair(k.second,k.first));
}}
Please re watch Prims algorithm concept video.