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

Commit e20cc51

Browse files
committed
Prepare method for running algorithms
1 parent d3bf264 commit e20cc51

4 files changed

Lines changed: 53 additions & 4 deletions

File tree

DirectedGraph.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,24 @@ void DirectedGraph::generate(int numberOfVertices, int density) {
7575
}
7676

7777
void DirectedGraph::runAlgorithm(char index, char arg1, int arg2, int arg3) {
78-
78+
if (index == 1) {
79+
if (arg1 == 0) {
80+
dijkstrasAlgorithmOnMatrix();
81+
} else if (arg1 == 1) {
82+
dijkstrasAlgorithmOnList();
83+
} else {
84+
throw "Nieznany blad!"; // should never be thrown
85+
}
86+
} else {
87+
throw "Algorytm nie istnieje!";
88+
}
7989
}
8090

8191
void DirectedGraph::test() {
8292

8393
}
8494

85-
// private
95+
// protected
8696

8797
void DirectedGraph::loadRawDataToMatrix(std::vector<int> rawData) {
8898
incidenceMatrix.clear();
@@ -130,3 +140,13 @@ void DirectedGraph::loadRawDataToList(std::vector<int> rawData) {
130140
adjacencyList[edgeBeginning].push_front({edgeEnd, edgeValue});
131141
}
132142
}
143+
144+
// private
145+
146+
void DirectedGraph::dijkstrasAlgorithmOnMatrix() {
147+
throw "Algorytm jeszcze nie zaimplementowany!";
148+
}
149+
150+
void DirectedGraph::dijkstrasAlgorithmOnList() {
151+
throw "Algorytm jeszcze nie zaimplementowany!";
152+
}

DirectedGraph.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class DirectedGraph : public Graph {
2323
protected:
2424
void loadRawDataToMatrix(std::vector<int> rawData) override ;
2525
void loadRawDataToList(std::vector<int> rawData) override ;
26+
27+
private:
28+
void dijkstrasAlgorithmOnMatrix();
29+
void dijkstrasAlgorithmOnList();
30+
2631
};
2732

2833

UndirectedGraph.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,24 @@ void UndirectedGraph::generate(int numberOfVertices, int density) {
7575
}
7676

7777
void UndirectedGraph::runAlgorithm(char index, char arg1, int arg2, int arg3) {
78-
78+
if (index == 1) {
79+
if (arg1 == 0) {
80+
primsAlgorithmOnMatrix();
81+
} else if (arg1 == 1) {
82+
primsAlgorithmOnList();
83+
} else {
84+
throw "Nieznany blad!"; // should never be thrown
85+
}
86+
} else {
87+
throw "Algorytm nie istnieje!";
88+
}
7989
}
8090

8191
void UndirectedGraph::test() {
8292

8393
}
8494

85-
// private
95+
// protected
8696

8797
void UndirectedGraph::loadRawDataToMatrix(vector<int> rawData) {
8898
incidenceMatrix.clear();
@@ -131,3 +141,13 @@ void UndirectedGraph::loadRawDataToList(std::vector<int> rawData) {
131141
adjacencyList[edgeEnd].push_front({edgeBeginning, edgeValue});
132142
}
133143
}
144+
145+
// private
146+
147+
void UndirectedGraph::primsAlgorithmOnMatrix() {
148+
throw "Algorytm jeszcze nie zaimplementowany!";
149+
}
150+
151+
void UndirectedGraph::primsAlgorithmOnList() {
152+
throw "Algorytm jeszcze nie zaimplementowany!";
153+
}

UndirectedGraph.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class UndirectedGraph : public Graph {
2424
void loadRawDataToMatrix(std::vector<int> rawData) override ;
2525
void loadRawDataToList(std::vector<int> rawData) override ;
2626

27+
private:
28+
void primsAlgorithmOnMatrix();
29+
void primsAlgorithmOnList();
30+
2731
};
2832

2933

0 commit comments

Comments
 (0)