Prims algo graphs

where i m going wrong in this ???

o/p is showing 0 instead of 17

Hey @hg11110000

for (auto p : g[best.second])
   {
           if (!visited[p.first]) q.push({p.second, p.first});//!visited[p.first] instead of !visited[best.second] 
   }