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 ADJACENCYLISTGRAPHH
#define ADJACENCYLISTGRAPHH
#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 AddVertexstd::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 AddDirectedEdgeVertex 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 GetEdgesFromVertex 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 GetEdgesToVertex 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 GetVertexstd::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 HasEdgeVertex fromVertex, Vertex toVertex override
TODO: Type your code here remove placeholder line below
return false;
;
#endif
#ifndef ADJACENCYMATRIXGRAPHH
#define ADJACENCYMATRIXGRAPHH
#include "DirectedGraph.h
class AdjacencyMatrixGraph : public DirectedGraph
protected:
std::vector vertices;
If matrixRowsXY is true, then an edge exists from verticesX to
verticesY
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 AddVertexstd::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 AddDirectedEdgeVertex 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 GetEdgesFromVertex 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 GetEdgesToVertex 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 GetVertexstd::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 HasEdgeVertex fromVertex, Vertex toVertex override
TODO: Type your code here remove placeholder line below
return false;
;
#endif
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
