Question: Create a C++ Graph class for undirected weighted graphs Graphs are stored as adjacency matrices. Vertexes are non-negative integers. Assume a graph will not have

 Create a C++ Graph class for undirected weighted graphs Graphs are

Create a C++ Graph class for undirected weighted graphs Graphs are stored as adjacency matrices. Vertexes are non-negative integers. Assume a graph will not have more than 100 vertexes. Weights are positive integers The private section should contain 1) the matrix representing the graph, and 2) the vertexes in the graph. The public section should contain a default constructor. When a graph is created, a 100 by 100 integer matrix for it is created and its components are all set to zeros, and the set of vertexes in the graph is set to empty Use a 100 component boolean array to specify ifa given vertex is in the graph or not. (E-E-to see if vertex i is in the graph, check if the component at index i is trve.) So initially this array would have all values set to false. Additional member functions should be included as follows: void addVertex (int vertex) adds vertex to the graph void addidge (int vertexi, int vertex2, int veight) adds an edge between vertexi and vertex2 with the specified integer weight. void resoveldge (int vertexi, int vertex2) removes the edge between vertexl and vertex2. void removeVertex (int vertex) removes veztex from the graph. bool isEdge (int vertexl, int vertex2) returns true if there is an edge between vertexi and vertex2. int edgeMeight (int vertexi, int vertex2) returns the weight of the edge between vertexi and vertex2 or zero if there is no edge. bool isheighbor (int vertexl, int vertex2) returns true if the graph contains an edge from vertexi to vertex2. string tostring converts the graph to a printable string representation, listing all vertex names followed by the start/finish of all edges with a dash between the 2 followed by the weight in parentheses, such as "10, 1, 2, 3: 0-1 (13), 1-2 (20), 1-3 (11), 2-3 (53)1" for the graph below

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!