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!!!

Edited 4 Years Ago by nicprog: n/a

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;

Edited 3 Years Ago by Nick Evan: Fixed formatting

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;
            }

Edited 3 Years Ago by Nick Evan: Fixed formatting

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?

Edited 3 Years Ago by Dani: Formatting fixed

This article has been dead for over six months. Start a new discussion instead.