Question
Finish the implimentation of this graph class. Then use it to print out the Vertex Distance Path Use a directed graph. class Graph { private:
Finish the implimentation of this graph class. Then use it to print out the Vertex Distance Path
Use a directed graph.
class Graph
{
private:
//Graph data structure here or create another class to implement it
?? public:
void insertVertex(int vertex); //inserts new vertex in graph
void insertEdge(int from, int to, int weight); //inserts new edge in graph
bool isEdge(int from, int to); //returns true if there is an edge between the vertices from and to
int getWeight(int from, int to); //returns the weight of the edge between the vertices from and to
vector
void printDijkstra(int source); //prints result of running Dijkstra's algorithm with source vertex
void printGraph(); //prints graph in a format sorted by ascending vertex and edge list
};
Must take in this input
Sample Input
10 1 1 1 2 1 3 1 4 2 1 2 3 2 2 3 7 2 2 4 5 2 3 4 15 2 4 1 4 6 1
Must produce this output
Sample Output
Vertex Distance Path 2 3 1-2 3 10 1-2-3 4 8 1-2-4
Here is the main that you will work with but do not alter the main only alter the class.
int main() { //DO NOT CHANGE THIS FUNCTION. CHANGE YOUR IMPLEMENTATION CODE TO MAKE IT WORK int noOfLines, operation, vertex, to, fro, weight,source,j; vector
C++ and please comment the code and use readable variables thanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started