Our main objective is to implement breadth-first-search ( BFS ) to print the vertices of a graph G. To get the full grade, you must annotate your code (i.e., write relevant comments throughout your...


Our main objective is to implement breadth-first-search (BFS) to print the vertices of a graph G.


To get the full grade, you must annotate your code (i.e., write relevant comments throughout your program) and proceed as follows:



  • Ask the user to enter the number of nodes of a graph G.

  • Ask the user to enter the edges of G (e.g., if the user enters 3 and 5; it means that there is an edge between nodes 3 and 5).

  • Store the graph G using an adjacency matrix.

  • Run BFS on G, starting form node 1 (i.e., we assume here that the start node is 1).

  • Use a queue to implement BFS. You may use the
    queue class
    from the library of the programming language you are using (so there is no need to implement your own class queue).

  • Write a main function to test your program, and make sure BFS is visiting the vertices of G as expected.



Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here