Question: ***PLEASE FOLLOW THE INSTRUCTION BELOW C++ Dijkstra's Algorithm Feel free to use STL for this project. Write a Dijkstra's Algorithm with 5 FUNCTIONS BELOW (in

***PLEASE FOLLOW THE INSTRUCTION BELOW

C++ Dijkstra's Algorithm Feel free to use STL for this project. Write a Dijkstra's Algorithm with 5 FUNCTIONS BELOW (in bold): void addVertex(std::string label) Creates and adds a vertex to the graph with label. No two vertices should have the same label. void removeVertex(std::string label) Removes the vertex with label from the graph. Also removes the edges between that vertex and the other vertices of the graph. void addEdge(std::string label1, std::string label2, unsigned long weight) Adds an edge of value weight to the graph between the vertex with label1 and the vertex with label2. A vertex with label1 and a vertex with label2 must both exist, there must not already be an edge between those vertices, and a vertex cannot have an edge to itself. void removeEdge(std::string label1, std::string label2) Removes the edge from the graph between the vertex with label1 and the vertex with label2. A vertex with label1 and a vertex with label2 must both exist and there must be an edge between those vertices unsigned long shortestPath(std::string startLabel, std::string endLabel, std::vector &path) Calculates the shortest path between the vertex with startLabel and the vertex with endLabel using Dijkstra's Algorithm. A vector is passed into the method that stores the shortest path between the vertices. The return value is the sum of the edges between the start and end vertices on the shortest path. ***Instruction**** Implementing an undirected weighted GraphADT and perform Dijkstra's Algorithm to find the shortest path between two vertices. The Graph can be implemented using either AN ADJACENCY LIST, ADJACENCY MATRIX, OR INCIDENCE MATRIX. We are given a TEST.cpp file to test this code so we don't need a main function because the test file included everything. So you can make a main function to test this code because the TEST.CPP file is too long so I can't post it on here. ***Example*** std::vector vertices1 = { "1", "2", "3", "4", "5", "6" }; std::vector> edges1 = { {"1", "2", 7}, {"1", "3", 9}, {"1", "6", 14}, {"2", "3", 10}, {"2", "4", 15}, {"3", "4", 11}, {"3", "6", 2}, {"4", "5", 6}, {"5", "6", 9} }; for (const auto label : vertices1) g.addVertex(label); for (const auto &tuple : edges1) g.addEdge(std::get<0>(tuple), std::get<1>(tuple), std::get<2>(tuple)); g.shortestPath("1", "5", path); // == 20 g.shortestPath("1", "5", path); // = { "1", "3", "6", "5"} ***Hints*** Though it may be appealing to use an adjacency matrix, it might be simpler to complete this algorithm using an adjacency list for each vertex. I suggest using a separate class for your edge and vertex. Remember to write a destructor for your graph ***files needed*** Graph.cpp //WORK IN THIS FILE Graph.hpp //WORK IN THIS FILE TEST.cpp //test file given, it has some test cases. catch.cpp //catch file given, it catchs errors GraphBase.hpp // this file is the base class and given ***Thank you****

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!