Thursday, October 7, 2010

C Programming - Floyds algorithm using dynamic programming

ALGORITHM
C Programming - Floyds algorithm using dynamic programming

#include
#include
#include
#include

#define MAX 7

void fnFloyds(int aiCost[MAX][MAX],int iN)
{
int iI,iJ,iK;
for(iK=0;iK
{
printf("\nTranstive Closure : %d\n",iK+1);
for(iI=0;iI
{
for(iJ=0;iJ
{
aiCost[iI][iJ]=min(aiCost[iI][iJ],(aiCost[iI][iK] + aiCost[iK][iJ]) );
printf(" %d ",aiCost[iI][iJ]);
}
printf("\n");
}
}
}


void main()
{
int aiCost[MAX][MAX],iI,iJ,iN;
clrscr();
printf("Enter the no of Vertices : ");
scanf("%d",&iN);
printf("\nEnter the Cost Matrix \n ");
for(iI=0;iI
for(iJ=0;iJ
scanf("%d",&aiCost[iI][iJ]);
fnFloyds(aiCost,iN);
getch();
}

2 comments:

  1. incomplete for loops, undefined min function, incomplete header files..

    ReplyDelete
  2. plzzzz provide the headers...............

    ReplyDelete