Skip to content

Instantly share code, notes, and snippets.

@sudikrt
Created August 4, 2017 18:20
Show Gist options
  • Save sudikrt/121c853556176ae5cb5f0b9ea3e4806b to your computer and use it in GitHub Desktop.
Save sudikrt/121c853556176ae5cb5f0b9ea3e4806b to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],b[10][10];
int n,i,k,j;
printf("Enter the number of vertices\n");
scanf("%d",&n);
printf("Enter the adjacency matrix\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++){
scanf("%d",&a[i][j]);
b[i][j]=a[i][j];
}
}
for(k=0;k<n;k++)
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(b[i][k]==1&&b[k][j]==1)
b[i][j]=1;
}
}
/*for(i=0;i<n;i++)
{
for(j=0;j<n;j++){
printf("%d\t",b[i][j]);
}
printf("\n");
}
printf("\n");*&*/
}
printf("Matrix\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++){
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("Trnsitive closer Matrix\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++){
printf("%d\t",b[i][j]);
}
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment