Lab preparation (at home)
Goal
Implement the directed graph data structure using the adjacency matrix
implementation. Use class Graph for your implementation.
class Graph {
private:
int numVertex;
int numEdge;
int ** matrix;
public:
Graph(int numVert);
~Graph();
void setEdge(int vertex1, int vertex2);
void delEdge(int vertex1, int vertex2);
void printGraphDepthFirst() const;
void printGraphBreathFirst() const;
bool containsEdge(int vertex1, int vertex2) const;
};
The constructor receives the number of vertices in the graph and allocates the
required memory. The destructor must deallocate the dynamically allocated
memory. Member function setEdge receives two vertices as parameters and
creates a directed edge from vertex1 to vertex2. Member function
delEdge deletes the edge from vertex1 to vertex2. Function
printGraphDepthFirst prints vertices of the graph using the depth-first
search traversal. A vertex is printed during its post-visit. Function
printGraphBreathFirst prints vertices of the graph using the breath-first
search traversal. Function containsEdge returns true is the edge from
vertex1 to vertex2 exists. If needed, you may add auxiliary private member functions
and data members.
Lab report
Finish the implementation and test it. Be prepared for modification of the
traversal functions in the lab.