#include<stdio.h>
#include<conio.h>
int main()
{
int
a[10][10],i,j,deg,m,n,totaldegree=0,deg1=0,connect=0,chck=0;
printf("@@@enter
the number of vertices and edges in the graph@@@\n");
scanf("%d%d",&m,&n);
printf("enter
the incidence matrix elements : \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("the
degree of each vertex is : \n");
for(j=0;j<n;j++)
{ deg1=0;
for(i=0;i<m;i++)
{
if(a[i][j]==1)
{ deg1++;
totaldegree++;
}
}
if(deg1==1)
{
printf("%d self loop present
\n",deg1);
totaldegree++;
for(i=0;i<m;i++)
{
if(a[i][j]==1)
{
a[i][j]=2;
}
}
}
}
printf("the total degree is %d \n",totaldegree);
for(i=0;i<m;i++)
{ deg=0;
connect=0;
for(j=0;j<n;j++)
{
if(a[i][j]>0)
{
deg=a[i][j]+deg;
}
else
{
connect++;
}
}
printf("degree of V%d = %d\n",i,deg);
}
if(chck>0)
{
if(connect==n)
{
printf("it is disconnected graph!\n");
}
}
else
{
printf("connected graph");
}
getch();
}
No comments:
Write comments