answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

int G[50][50],n,i,j,h,k;

void FGraph();

int findR();

void main()

{

clrscr();

printf("\t\t\tmultistage graph");

printf("\n enter the no of vertices:");

scanf("%d",&n);

printf("\n there is a edge between the follwing vertices enter its weight else 0:\n");

for (i=1;i<=n;i++)

for(j=1;j<=n;j++)

{

G[I][J]=0;

IF(I!=J)&&(i<J))

{

printf ("%d and%d:",i,j);

scanf(%d,&G[i][j]);

}

}

FGraph();

getch();

}

void FGraph()

{

int cost[50],d[50],p[50],r;

for(i=1;i<=n;i++)

cost[i]=0;

for(j=n-1;j>=1;j++)

{

r=findR(j+1);

cost[j]=G[j][r]+cost[r];

d[j]=r;

}

p[1]=1;p[k]=n;

for(j=2;j<k;j++)

p[i]=d[p[j-1]];

printf("%d-",d[1]);

for(j=2;j<n;j++)

{

if((d[j]==d[j-1])(d[j]==0))

continue;

if(d[j]<=n)

printf("%d-"d[j]);

}

printf("%d",n);

}

int findR(int cu)

{

int r1=n+1;

for(h=1;h<=n;h++)

{if((G[h][cu]!=0)&&(r1==n+1)){

r1=j;

continue;

}

if(G[h][cu]!=0)

{

if(G[h][cu]<G[r1][cu])

r1=h;

}}

return r1;

}sorry i have answerd in c++

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the c code for multistage graph?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Graph colouring method in c source code?

pls help


What is advantage and disadvantages of multistage amplifier?

A multistage amplifier is composed of several single stage amplifiers.


What is DAG in compiler?

Directed Acyclic Graph,Used to derive TAC- three address code to generate target code.


How to generate control flow graph from Java code?

I use Control Flow Graph Factory to generate control flow graphs from Java methods.http://www.drgarbage.com/control-flow-graph-factory-3-5.htmlBest,Paul


Why c is machine independent language?

C source code is portable; it can be compiled upon any machine with a suitable C compiler in order to produce the machine-dependant code (the machine code). However, C can also be used to write machine-dependant code, or code that is dependant upon specific platforms. In order to be completely portable, the code must use the C standard library and/or generic libraries.

Related questions

What is meant by multistage graph?

20000000000


What are the two applications of dynamic programming?

1)Multistage graph 2)Travelling salesman problem


Graph colouring method in c source code?

pls help


Advantages of multistage sampling?

Advantages of multistage sampling?


How can you describe the graph of the equation ax by c?

The graph of ax + by = c is a straight line going through the points (0, c/b) and (c/a, 0).


What type of equation has a graph that is horizontal?

It is likely that a horizontal line on a graph will have the equation y=c, where c is a variable.


How do you graph a constant?

The graph of y = c, a constant will be a straight line parallel to the x-axis and c units from it..


What is advantage and disadvantages of multistage amplifier?

A multistage amplifier is composed of several single stage amplifiers.


What graph graph indicates that there is a linear relationship between the dependent variable and the independent variable?

a graph of the independent variable and dependant that shows a graph with a fixed gradient (I.E a line graph) The equation of the graph will be given by y = mx +c where m is the gradient and c is a constant


How does adding a constant c to x in the parent graph y equals x affect the graph?

If y = f(x), then y = f(x + c) is the same graph shifted c units to the left (or right if c is negative) along the x-axis For y = x, by changing x to x + c, the above shift is indistinguishable from shifting the graph c units up (or down if c is negative) the y-axis.


Example of multistage sampling?

the combinitoin of any random samples is called multistage samplinag. it is the expensive form of cluster samling. when each elements in cluster are expensive then we use multistage sampling.


What can you say about the graph Ax plus By equals C about the graph Ax plus By equals C?

It is a straight line with gradient -A/B and intercept C/B.