Question: I can only edit two files AdjacencyListGraph.h and AdjacencyMatrixGraph. Below I have added those two files #ifndef ADJACENCYLISTGRAPH _ H #define ADJACENCYLISTGRAPH _ H #include

I can only edit two files AdjacencyListGraph.h and AdjacencyMatrixGraph. Below I have added those two files
#ifndef ADJACENCYLISTGRAPH_H
#define ADJACENCYLISTGRAPH_H
#include "DirectedGraph.h"
#include "AdjacencyListVertex.h"
class AdjacencyListGraph : public DirectedGraph {
protected:
std::vector vertices;
public:
virtual ~AdjacencyListGraph(){
for (AdjacencyListVertex* vertex : vertices){
delete vertex;
}
}
// Creates and adds a new vertex to the graph, provided a vertex with the
// same label doesn't already exist in the graph. Returns the new vertex on
// success, nullptr on failure.
virtual Vertex* AddVertex(std::string newVertexLabel) override {
// TODO: Type your code here (remove placeholder line below)
return nullptr;
}
// Adds a directed edge from the first to the second vertex. If the edge
// already exists in the graph, no change is made and false is returned.
// Otherwise the new edge is added and true is returned.
virtual bool AddDirectedEdge(Vertex* fromVertex, Vertex* toVertex) override {
// TODO: Type your code here (remove placeholder line below)
return false;
}
// Returns a vector of edges with the specified fromVertex.
virtual std::vector GetEdgesFrom(Vertex* fromVertex) override {
// TODO: Type your code here (remove placeholder line below)
return std::vector();
}
// Returns a vector of edges with the specified toVertex.
virtual std::vector GetEdgesTo(Vertex* toVertex) override {
// TODO: Type your code here (remove placeholder line below)
return std::vector();
}
// Returns a vertex with a matching label, or nullptr if no such vertex
// exists
virtual Vertex* GetVertex(std::string vertexLabel) override {
// TODO: Type your code here (remove placeholder line below)
return nullptr;
}
// Returns true if this graph has an edge from fromVertex to toVertex
virtual bool HasEdge(Vertex* fromVertex, Vertex* toVertex) override {
// TODO: Type your code here (remove placeholder line below)
return false;
}
};
#endif
#ifndef ADJACENCYMATRIXGRAPH_H
#define ADJACENCYMATRIXGRAPH_H
#include "DirectedGraph.h"
class AdjacencyMatrixGraph : public DirectedGraph {
protected:
std::vector vertices;
// If matrixRows[X][Y] is true, then an edge exists from vertices[X] to
// vertices[Y]
std::vector> matrixRows;
// TODO: Type your additional code here, if desired
public:
virtual ~AdjacencyMatrixGraph(){
for (Vertex* vertex : vertices){
delete vertex;
}
}
// Creates and adds a new vertex to the graph, provided a vertex with the
// same label doesn't already exist in the graph. Returns the new vertex on
// success, nullptr on failure.
virtual Vertex* AddVertex(std::string newVertexLabel) override {
// TODO: Type your code here (remove placeholder line below)
return nullptr;
}
// Adds a directed edge from the first to the second vertex. If the edge
// already exists in the graph, no change is made and false is returned.
// Otherwise the new edge is added and true is returned.
virtual bool AddDirectedEdge(Vertex* fromVertex, Vertex* toVertex) override {
// TODO: Type your code here (remove placeholder line below)
return false;
}
// Returns a vector of edges with the specified fromVertex.
virtual std::vector GetEdgesFrom(Vertex* fromVertex) override {
// TODO: Type your code here (remove placeholder line below)
return std::vector();
}
// Returns a vector of edges with the specified toVertex.
virtual std::vector GetEdgesTo(Vertex* toVertex) override {
// TODO: Type your code here (remove placeholder line below)
return std::vector();
}
// Returns a vertex with a matching label, or nullptr if no such vertex
// exists
virtual Vertex* GetVertex(std::string vertexLabel) override {
// TODO: Type your code here (remove placeholder line below)
return nullptr;
}
// Returns true if this graph has an edge from fromVertex to toVertex
virtual bool HasEdge(Vertex* fromVertex, Vertex* toVertex) override {
// TODO: Type your code here (remove placeholder line below)
return false;
}
};
#endif
 I can only edit two files AdjacencyListGraph.h and AdjacencyMatrixGraph. Below I

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!