0

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

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by nicprog
0

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

0

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 by nicprog: n/a

0

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 by Nick Evan: Fixed formatting

0
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 by Nick Evan: Fixed formatting

0
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 by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.