No idea. It would help to tell us what it is intended to do and what it is actually doing, and maybe include the main function so we can see how it is called and how the global variables are initialized.
On May 15, 1:45 pm, Edu <[email protected]> wrote: > Hi, this should be working, where is the problem? > > const int INF=999999; > > int n=6; > int weights[6][6]; > int parent[6]; > int idistance[6]; > int rec[6]; > > struct lesst{ > bool operator()(const int&a,const int&b){ > return (idistance[a]>idistance[b]); > } > > }; > > int prim(int s){ > int u,v,i; > priority_queue<int,vector<int>,lesst>Q; > idistance[s]=0; > Q.push(s); > for(i=0;i<n;++i){ > if(i==s)continue; > idistance[i]=INF; > parent[i]=-1; > Q.push(i); > } > while(!Q.empty()){ > u=Q.top(); > rec[u]=1; > Q.pop(); > for(v=0;v<n;++v){ > if(weights[u][v]==0); > else if(!rec[v] && weights[u][v]<idistance[v]){ > parent[v]=u; > idistance[v]=weights[u][v]; > } > } > } > return idistance[s]; > > } > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
