Question
Consider the following definition of a Graph. The private attributes of this class are: V, and E. V is a 1-D array that represents the
Consider the following definition of a Graph. The private attributes of this class are: V, and E. V is a 1-D array that represents the values inserted in the vertices. E is a 2-D array that represents the edges between the vertices using the Adjacency matrix. Header: #include using namespace std; const int SIZE = 5; // Size of vertices class Graph { public: void build(); void DFS_print(int v); private: int V[SIZE]; // Vertices int E[SIZE][SIZE]; // Edges };
1) Write the implementation for the build () member function that builds the following graph.
2) Write the implementation for the DFS_print(int v) member function that prints out the graph content (using the depth-first-search method, and starting from vertex v) to the output screen.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started