Question: Please help me with this C++ problem. In the c++ code below, I have created a connected graph with 9 vertices. I only know how

Please help me with this C++ problem. In the c++ code below, I have created a connected graph with 9 vertices. I only know how to represent the graph with adjacency list, but I need to write a function that is able to print each node of the graph in the following way:(1st row: 1 2 3, 2nd row: 4 5 6, 3rd row: 7 8 9).

Please help me with this C++ problem. In the c++ code below,

This is my code:

#include #include using namespace std;

int main() { vector adj[100]; int n=9;/umber of vertices. adj[1].push_back(2); adj[2].push_back(1); adj[1].push_back(4); adj[4].push_back(1); adj[2].push_back(3); adj[3].push_back(2); adj[2].push_back(5); adj[5].push_back(2); adj[3].push_back(6); adj[6].push_back(3); adj[4].push_back(5); adj[5].push_back(4); adj[4].push_back(7); adj[7].push_back(4); adj[5].push_back(6); adj[6].push_back(5); adj[5].push_back(8); adj[8].push_back(5); adj[6].push_back(9); adj[9].push_back(6); adj[7].push_back(8); adj[8].push_back(7); adj[8].push_back(9); adj[9].push_back(8); //print the graph with adjacency list. for(int i=1;i"

Thank you so much.

||1 |2| 3| | 4| 5 |6| |71819 | - - - - - - - - - - ||1 |2| 3| | 4| 5 |6| |71819 |

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!