Skip to main content

Posts

Showing posts with the label Graph

Breath First Search (BFS) in C Programming

#include #include #define MAX 20 #define TRUE 1 #define FALSE 0 int g[MAX][MAX]; int v[MAX]; int Q[MAX]; int n; int front,rear; void create(); void BFS(int); void main() { int i,j; char ans; clrscr(); printf("\n----------------------------------------------------"); printf("\n BREADTH FIRST SEARCH"); printf("\n----------------------------------------------------"); create(); getch(); printf("\n Adjacency Matrix for the graph is:"); printf("\n----------------------------------------------------"); for(i=0;i =MAX) printf("\n Invalid Vertex"); else { printf("\n The Depth First Search of the Graph is:"); printf("\n----------------------------------------------------\n"); BFS(i); printf("\n----------------------------------------------------\n"); } printf("\n Dou want to Traverse By other node?"); ans=getche(); }while(ans=='y' ||...

Depth First Search (DFS) in C Programming

#include #include #define MAX 20 #define TRUE 1 #define FALSE 0 int g[MAX][MAX]; int v[MAX]; int n; void create(); void DFS(); void main() { int i,j; char ans; clrscr(); printf("\n----------------------------------------------------"); printf("\n DEPTH FIRST SEARCH"); printf("\n----------------------------------------------------"); create(); getch(); printf("\n Adjacency Matrix for the graph is:"); printf("\n----------------------------------------------------"); for(i=0;i =MAX) printf("\n Invalid Vertex"); else { printf("\n The Depth First Search of the Graph is:"); printf("\n----------------------------------------------------\n"); DFS(i); printf("\n----------------------------------------------------\n"); } printf("\n Dou want to Traverse By other node?"); ans=getch(); }while(ans=='y' || ans=='Y'); } void create(...