Question: For this exercise, you will need to download the cpp file. This program is on graphs and has known errors, which you will fix them

For this exercise, you will need to download the cpp file. This program is on graphs and has known errors, which you will fix them using gdb. You will zip together screenshots using gdb when the error is found and your .cpp file with a brief explanation on how you fixed it. Please help me figure outm thank you! xxx.cpp #include  #include  using namespace std; #ifndef GRAPH_H #define GRAPH_H template struct vertex; template struct adjVertex{ vertex *v; int weight; }; template struct vertex{ T name; vector> adj; }; template class Graph { public: Graph(); ~Graph(); void addEdge(T v1, T v2, int weight); void addVertex(T name); void displayEdges(); protected: private: vector > vertices; }; // Start implementation of member objects template Graph::Graph() { } template Graph::~Graph() { } template void Graph::addEdge(T v1, T v2, int weight){ for(int i = 0; i < vertices.size(); i++){ if(vertices[i].name == v1){ for(int j = 0; j < vertices.size(); j++){ if(vertices[j].name == v2 && i != j){ adjVertex av; av.v = &vertices[j]; av.weight = weight; vertices[i].adj.push_back(av); } } } } } template void Graph::addVertex(T n){ bool found = false; for(int i = 0; i < vertices.size()+1; i++){ if(vertices[i].name == n){ found = true; cout< v; v.name = n; vertices.push_back(v); } } template void Graph::displayEdges(){ //loop through all vertices and adjacent vertices for(int i = 0; i < vertices.size(); i++){ cout<"; for(int j = 0; j < vertices[i+1].adj.size(); j++){ i = j; cout<name<<"***"; } cout< g; g.addVertex(1); g.addVertex(2); g.addVertex(3); g.addVertex(4); g.addEdge(1,2,30); g.addEdge(3,4,300); g.addEdge(2,4,10); g.displayEdges(); return 0; } 

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!