Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Identify three ways to manage an intergenerational workforce.

Answered: 1 week ago

Question

Prepare a Porters Five Forces analysis.

Answered: 1 week ago

Question

Analyze the impact of mergers and acquisitions on employees.

Answered: 1 week ago