Title | DFS & BFS ( C Code) |
---|---|
Author | Prashant Saini |
Course | Data Structures |
Institution | University of Mumbai |
Pages | 4 |
File Size | 50.9 KB |
File Type | |
Total Downloads | 23 |
Total Views | 146 |
Intuitively, a graph is a structure that consists of disjoint nodes connected by links.
Mathematically, the nodes are called vertices and links or arcs are called edges....
Experiment-12 //Implementations of Graph menu driven program (DFS & BSF) #include #include #define MAX 20 int a[20][20],visited[20],n,q[MAX],f=0,r=-1; void dfs(int v); void bfs(int v); int isEmpty(); int isFull(); void enqueue(int v); int dequeue(); void input(); void main() { int i,j,ch; clrscr(); do { printf("\nEnter choice:\t1.DFS\t2.BFS\t3.Exit\n"); scanf("%d",&ch); switch(ch) { case 1: input(); dfs(1); break; case 2: input(); bfs(1); break; case 3: exit(0); } }while(ch!=3); getch(); } void input() { int i,j; printf("Enter no. of vertices:"); scanf("%d",&n); for(i=1;i...