Thursday 24 April 2014

WAP to number of isolated vertices in a Graph

#include<stdio.h>
#include<conio.h>

void main()
{

  int i,j;
  int flag=0, count3;
  int total;
  int 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");
  }

for (i=0;i<m;i++)
 {
   count3=0;
     for (j=0;j<m;j++)
     {
       if(a[i][j]==1)
      {
             count3=count3+1;
      }
     }
       if (count3==0)
       {
            printf ("\n>>>isolated vertex found at vertex = %d\n",i+1);
       }
 }

  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-2022