Thursday, 24 April 2014

Wap to Count the number of odd degree vertices, number of even degree vertices and degree of each vertex and hence the total degree of a Graph using adjacent Matrix.

#include "stdio.h"
#include "conio.h"
void main()
{
  int i,j;
  int count2;
  int m,n,a[10][10];
   clrscr();
printf("\n @@@ Enter the no of edge and vertice@@@ \n-> ");
  scanf ("%d%d",&m,&n);
  printf ("\n Enter the adjacency matrix :  \n");
  for (i=0;i
  {
    for(j=0;j
            {
             scanf("%d",&a[i][j]);
            }
  }
total=0;
  for (i=0;i
  {
 count=0;
    for(j=0;j
            {
               if ( a[i][j]==1 && i!=j)
                  {
                            count=count+1;
                  }
                            else
                                     if(i==j && a[i][j]==1)
                              {
                                     count=count+2;
                                     printf ("\n>>>vertex %d contain self loop in a graph",i+1);
                              }

            }
                 printf ("\n>>>Degree of vertex %d = %d",i+1,count);
                 total=total+count;

                 if (count%2==0)
                        {
                           flag=flag+count;
                        }

               if (count%2 == 0)
              {
                even++;
              }
               else
              {
                odd++;
              }
  }
  printf ("\n>> Number of odd degree count is %d",odd);
  printf ("\n>> Number of even degere count is %d",even);
  printf ("\n>> Total degree is   = %d",total); getch();

 }

No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2016