#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
int
flag=0,count;
int total;
int
R[10],C[10],m,a[10][10];
clrscr();
printf("\n @@@ Enter the no of vertices in a graph : @@@\n->
");
scanf
("%d",&m);
printf
("\n Enter the adjacency matrix :
\n");
for
(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
printf ("Enter %d row and ",i);
printf (" %d column -> ",j);
scanf("%d",&a[i][j]);
}
}
printf
("\n>>> The entered adjacency matrix is \n" );
for
(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
printf ("%3d",a[i][j]);
}
printf
("\n");
}
printf ("\n>> Degree each vertices are :
");
total=0;
for
(i=0;i<m;i++)
{
count=0;
for(j=0;j<m;j++)
{
if ( a[i][j]==1 && i!=j)
{
count=count+1;
}
else
if(i==j && a[i][j]==1)
{
count=count+2;
}
}
total=total+count;
if (count%2==0)
{
flag=flag+count;
}
}
printf
("\n>> Total degree is =
%d",total);
if (flag==total)
{
printf ("\n>> The graph is
eular");
}
else
{
printf ("\n>> The graph is not
eular");
}
getch();
}
No comments:
Write comments