0% found this document useful (0 votes)
3 views5 pages

PP4 Doc S2025

The document outlines the requirements for Programming Project 4, which involves implementing an undirected weighted Graph ADT and applying Dijkstra's Algorithm to find the shortest path between vertices. Teams of four are tasked with coding, creating a report, and delivering a presentation, with specific methods and deliverables outlined for the graph implementation. The project will be evaluated based on criteria including the correctness of the shortest path calculations, adherence to object-oriented design principles, and the quality of documentation and presentation.

Uploaded by

Kiet Do
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

PP4 Doc S2025

The document outlines the requirements for Programming Project 4, which involves implementing an undirected weighted Graph ADT and applying Dijkstra's Algorithm to find the shortest path between vertices. Teams of four are tasked with coding, creating a report, and delivering a presentation, with specific methods and deliverables outlined for the graph implementation. The project will be evaluated based on criteria including the correctness of the shortest path calculations, adherence to object-oriented design principles, and the quality of documentation and presentation.

Uploaded by

Kiet Do
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Dijkstra's Algorithm

COP 4530 Programming Project 4


Instructions
For Programming Project 4, you will be implementing an undirected weighted Graph ADT and
performing Dijkstra's Algorithm to find the shortest path between two vertices. Your graph can
be implemented using either an adjacency list, adjacency matrix, or an incidence matrix. Your
graph will implement methods that add and remove vertices, add and remove edges, and
calculate the shortest path. You can only use the class <string> and class <vector> from
standard libraries.

A large portion of this assignment is researching and implementing Dijkstra's Algorithm. There is
information about this algorithm in your textbook and widely available on the web.

Working in teams of four, your project must consist of codes, report (2-3 pages), presentation (slides),
and zipped together.
The final report should be nicely formatted and include the description of your task, summary of
results, main conclusions, discussion of any surprising discoveries, and references.
The project concludes with a 15-20 min presentation held during the classes including the live demo.
Each group members must present some part of project.

Abstract Class Methods


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<std::string> &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.
Examples
Below in an example of the functionality of the implemented graph:
Graph 1
std::vector<std::string> vertices1 = { "1", "2", "3", "4", "5", "6" };
std::vector<std::tuple<std::string, std::string, unsigned long>>
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} };

g.shortestPath("1", "5", path); // == 20


g.shortestPath("1", "5", path); // = { "1", "3", "6", "5" }
Graph 2
std::vector<std::string> vertices2 {
"BSN", "LIB", "ENB", "MSC", "CAS", "SUB", "SUN"
};
std::vector<EdgeStruct> edges2 {
{"BSN", "LIB", 871}, {"BSN", "CAS", 1672}, {"BSN", "MSC", 2355}, {"SUN", "SUB",
1265},
{"LIB", "MSC", 1615}, {"LIB", "SUN", 1847}, {"ENB", "SUN", 2885},
{"ENB", "CAS", 454}, {"ENB", "LIB", 1078}
};
g.shortestPath("ENB", "SUN", path) == 2885
g.shortestPath("LIB", "CAS", path) == 1532

Deliverables
Please submit complete projects as zipped folders. The zipped folder should contain:
· Graph.cpp (Your written Graph class)
· Graph.hpp (Your written Graph
class)
· GraphBase.hpp (The provided base class)
#ifndef GRAPHBASE_H
#define GRAPHBASE_H

#include <vector>
#include <string>

class GraphBase {
virtual void addVertex(std::string label) = 0;
virtual void removeVertex(std::string label) = 0;
virtual void addEdge(std::string label1, std::string label2, unsigned long
weight) = 0;
virtual void removeEdge(std::string label1, std::string label2) = 0;
virtual unsigned long shortestPath(std::string startLabel, std::string
endLabel, std::vector<std::string> &path) = 0;
};

#endif
· main.cpp (your written file)
Report
Slides
And any additional source and header files needed for your project.

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 graphs!


Rubric
Any code that does not compile will receive a zero for this project.
Criteria Points
13
Should calculate the distance of the shortest path for graph 1

Should have the labels for the shortest path for graph 1 13

Should calculate the distance of the shortest path for graph 2 13

Should have the labels for the shortest path for graph 2 13

Code implements Dijkstra's Algorithm 20

Code uses object oriented design principles


(Separate headers and sources, where applicable) 5

Code is well documented 5

Report 8

Presentation 10

Total Points 100

You might also like