C++ program to Represent a graph using adjacency list and perform DFS and BFS



Represent a graph using adjacency list and perform DFS and BFS



OUTPUT:

1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 1

Enter no. of vertices :8

Enter no of edges :10

Enter an edge (u,v)  :0 1

Enter an edge (u,v)  :0 2

Enter an edge (u,v)  :1 3

Enter an edge (u,v)  :1 4

Enter an edge (u,v)  :2 5

Enter an edge (u,v)  :2 6

Enter an edge (u,v)  :3 7

Enter an edge (u,v)  : 4 7

Enter an edge (u,v)  :5 7

Enter an edge (u,v)  :6 7
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 2

Enter starting node : 1

 Visit  1
visit  0
visit  3
visit  4
visit  2
visit  7
visit  5
visit  6

1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 3

Enter starting node : 1

1
0
2
5
7
3
4
6

1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 4