algorithm - Graph is connected or not ! in c language for ford fulkersion -


// created part of ford fulkersion algorithm

#include<stdio.h> #include<conio.h>  void main() {     int v,i,e,ch[20],sv[20],count=0,s,j;     clrscr();     printf("enter no of vertices :");     scanf("%d",&v);     for(i=1;i<=v;i++)     {         printf("enter vertices %d",i);         scanf("%d",&sv[i]);     }     printf("enter starting node : ");     scanf("%d",&s); 

//problem in below loop(logic not working ) if 1 have solution please !

    for(i=s;i<=v-1;i++)     {         for(j=i+1;j<=v;j++)         {             printf("conn betn %d , %d",i,j);             scanf("%d",&ch[i]);             if(ch[i]!=1)             {                 break;             }             else if(ch[i]==1)             {                 count++;             }         }     } 

//----------------------------------------------------------

if(count>=v) {     printf("graph connected"); } else {     printf("graph disconnected"); } getch(); 

}

your algorithm wrong. assuming if have @ least v edges, graph connected. if have graph this, 6 nodes , 6 edges, still not connected:

enter image description here


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -