Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

Numbers of year in existence of ICANN

Answered: 1 week ago

Question

1. Who is responsible for resolving this dilemma?

Answered: 1 week ago

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago