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

Commit 6453190

Browse files
committed
Move loadData method to super class
1 parent 5b9b0e5 commit 6453190

6 files changed

Lines changed: 38 additions & 13 deletions

File tree

DirectedGraph.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ std::string DirectedGraph::getAvailableAlgorithms() {
1818
return output;
1919
}
2020

21-
void DirectedGraph::loadDataFrom(std::string fileName) {
22-
vector<int> rawData = loadRawDataFrom(fileName);
23-
}
24-
2521
void DirectedGraph::generate(int numberOfVertices, int density) {
2622

2723
}
@@ -33,3 +29,13 @@ void DirectedGraph::runAlgorithm(int index) {
3329
void DirectedGraph::test() {
3430

3531
}
32+
33+
// private
34+
35+
void DirectedGraph::loadRawDataToMatrix(std::vector<int> rawData) {
36+
37+
}
38+
39+
void DirectedGraph::loadRawDataToList(std::vector<int> rawData) {
40+
41+
}

DirectedGraph.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ class DirectedGraph : public Graph {
1414

1515
std::string getAvailableAlgorithms() override;
1616

17-
void loadDataFrom(std::string fileName) override;
18-
1917
void generate(int numberOfVertices, int density) override;
2018

2119
void runAlgorithm(int index) override;
2220

2321
void test() override;
2422

23+
protected:
24+
void loadRawDataToMatrix(std::vector<int> rawData) override ;
25+
void loadRawDataToList(std::vector<int> rawData) override ;
26+
2527
};
2628

2729

Graph.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ string Graph::printAdjacencyList() {
112112
return output;
113113
}
114114

115+
void Graph::loadDataFrom(std::string fileName) {
116+
vector<int> rawData = loadRawDataFrom(fileName);
117+
loadRawDataToMatrix(rawData);
118+
loadRawDataToList(rawData);
119+
}
120+
115121
// protected
116122

117123
vector<int> Graph::loadRawDataFrom(string path) {

Graph.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Graph {
4141

4242
std::string printAdjacencyList();
4343

44-
virtual void loadDataFrom(std::string fileName)= 0;
44+
void loadDataFrom(std::string fileName);
4545

4646
virtual void generate(int numberOfVertices, int density)= 0;
4747

@@ -53,6 +53,9 @@ class Graph {
5353

5454
std::vector<int> loadRawDataFrom(std::string path);
5555

56+
virtual void loadRawDataToMatrix(std::vector<int> rawData)= 0;
57+
virtual void loadRawDataToList(std::vector<int> rawData)= 0;
58+
5659
};
5760

5861

UndirectedGraph.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ std::string UndirectedGraph::getAvailableAlgorithms() {
1818
return output;
1919
}
2020

21-
void UndirectedGraph::loadDataFrom(std::string fileName) {
22-
vector<int> rawData = loadRawDataFrom(fileName);
23-
}
24-
2521
void UndirectedGraph::generate(int numberOfVertices, int density) {
2622

2723
}
@@ -33,3 +29,13 @@ void UndirectedGraph::runAlgorithm(int index) {
3329
void UndirectedGraph::test() {
3430

3531
}
32+
33+
// private
34+
35+
void UndirectedGraph::loadRawDataToMatrix(vector<int> rawData) {
36+
37+
}
38+
39+
void UndirectedGraph::loadRawDataToList(std::vector<int> rawData) {
40+
41+
}

UndirectedGraph.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ class UndirectedGraph : public Graph {
1414

1515
std::string getAvailableAlgorithms() override;
1616

17-
void loadDataFrom(std::string fileName) override;
18-
1917
void generate(int numberOfVertices, int density) override;
2018

2119
void runAlgorithm(int index) override;
2220

2321
void test() override;
2422

23+
protected:
24+
void loadRawDataToMatrix(std::vector<int> rawData) override ;
25+
void loadRawDataToList(std::vector<int> rawData) override ;
26+
2527
};
2628

2729

0 commit comments

Comments
 (0)