Skip to content
This repository was archived by the owner on May 27, 2019. It is now read-only.

Commit 2fa5d95

Browse files
committed
Make Dijkstra's algorithms return string
1 parent d26d2bd commit 2fa5d95

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

DirectedGraph.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,21 @@ void DirectedGraph::generate(int numberOfVertices, int density, int range) {
7575
}
7676

7777
string DirectedGraph::runAlgorithm(char index, char arg1, int arg2, int arg3) {
78+
string output;
79+
7880
if (index == 1) {
7981
if (arg1 == 0) {
80-
dijkstrasAlgorithmOnMatrix();
82+
output = dijkstrasAlgorithmOnMatrix();
8183
} else if (arg1 == 1) {
82-
dijkstrasAlgorithmOnList();
84+
output = dijkstrasAlgorithmOnList();
8385
} else {
8486
throw "Nieznany blad!"; // should never be thrown
8587
}
8688
} else {
8789
throw "Algorytm nie istnieje!";
8890
}
91+
92+
return output;
8993
}
9094

9195
void DirectedGraph::test() {
@@ -143,10 +147,10 @@ void DirectedGraph::loadRawDataToList(std::vector<int> rawData) {
143147

144148
// private
145149

146-
void DirectedGraph::dijkstrasAlgorithmOnMatrix() {
150+
string DirectedGraph::dijkstrasAlgorithmOnMatrix() {
147151
throw "Algorytm jeszcze nie zaimplementowany!";
148152
}
149153

150-
void DirectedGraph::dijkstrasAlgorithmOnList() {
154+
string DirectedGraph::dijkstrasAlgorithmOnList() {
151155
throw "Algorytm jeszcze nie zaimplementowany!";
152156
}

DirectedGraph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class DirectedGraph : public Graph {
2525
void loadRawDataToList(std::vector<int> rawData) override ;
2626

2727
private:
28-
void dijkstrasAlgorithmOnMatrix();
29-
void dijkstrasAlgorithmOnList();
28+
std::string dijkstrasAlgorithmOnMatrix();
29+
std::string dijkstrasAlgorithmOnList();
3030

3131
};
3232

0 commit comments

Comments
 (0)