how to write this in c++???


while (Q not empty)
{
u = deleteMin (Q)
for each v adjacent to u
if (v is in Q and w(u; v) < key[v]) {
key[v] = w(u; v); //decrease key
T[v] = u; }}

Start by understanding the algorithm, them use your knowledge of C++ to write equivalent code.

basic i want to find the smaller path of graph, found it, the problem is how to connect the vertices with other vertice with edges.

the idea is check the num edges and take the the smaller!!!

how to minimum path and take the position of these???

for(int u=0;u<nodes;u++)
        {
            for(int v=0;v<nodes;v++)
            {
                dist[u][v]=edges[u][v]+edges[u][0];
                cout << dist[u][v] << endl << endl;
                ma.min1(dist,nodes);
                //cout <<  u << "-->" << v << endl;


            }
        }   
        //cout << ma.min1(edges,nodes)<< endl;
    cout << endl << endl;


    cout << "the sum of total minimum path is: " << ma.min1(dist,nodes) << endl;
for(int v=0;v<nodes;v++)
            {
                cout << "The position are: " << v << "  ";


                if(edges[v]<dist[v])
                {
                    dist[v]=edges[v]; how to measure it from one point to other point for i find the minimun path?? 
                }cout <<"The minnimun spanning tree is(Path): " << ma.min1(dist,nodes) << endl;
            }
void tree::swap(int a[],int i,int j)
{
    int temp;

    temp=a[i];
    a[i]=a[i+1];
    a[i+1]=temp;

}

the function doesn't take the last number and give empty"-858993460"
how to fix?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.