__Distance Vector Routing__

You can also Download the Program code and corresponding output

to Download

click here

#include

main()

{

int n,nadj,delay[15],i,j,k,distance[15][15],min,index;

int sum[15][15],suml[15],shortdelay[15];

char source,node[15],adj[15],finalnode[15];

clrscr();

printf("\n Enter the no of nodes\t");

scanf("%d",&n);

printf("\n Enter the names of the nodes:\t");

for(i=0;i<

{

flushall();

node[i]=getchar();

}

printf(" \n Enter the source node \t");

flushall();

source=getchar();

printf("\n Enter the no of Adjacent nodes\t");

scanf("%d",&nadj);

printf("\n Enter the names of the adjacent nodes\t");

for(i=0;i

{ flushall();

adj[i]=getchar();

}

printf("\nEnter the delay of the nodes\t");

for(i=0;i

scanf("%d",&delay[i]);

printf("\n Enter the distances to all the nodes from the adjacent nodes");

for(i=0;i

{

for(j=0;j

{

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

}

}

for(i=0;i

{

for(j=0;j

{

sum[i][j]=delay[i]+distance[i][j];

}

}

printf(" \n NODES \t\t ADJACENT NODES\t\t SHORT DELAY:");

k=0;

while(k!=n)

{

for(j=0;j

suml[j]=sum[j][k];

min=3200;

for(j=0;j

{

if(suml[j]

{

min=suml[j];

index=j;

}

}

finalnode[k]=adj[index];

shortdelay[k]=min;

k++;

}

for(i=0;i

{

printf("\n %c",node[i]);

if(node[i]==source)

{

printf("\t\t");

printf(0);

printf("\n");

}

else

{

printf("\t\t\t %c",finalnode[i]);

printf("\t\t\t %d",shortdelay[i]);

printf("\n");

}

}

getch();

}

## 0 comments:

## Post a Comment