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

Commit c1935e7

Browse files
committed
Merge branch 'deny-loop' into development
2 parents 0f641c1 + a85594d commit c1935e7

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

DirectedGraph.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ void DirectedGraph::loadRawDataToMatrix(std::vector<int> rawData) {
4747
int edgeEnd = rawData[i++];
4848
int edgeValue = rawData[i++];
4949

50+
if (edgeBeginning == edgeEnd) {
51+
incidenceMatrix.clear();
52+
throw "Petle sa nieakceptowane!";
53+
}
54+
5055
incidenceMatrix[j][edgeEnd] = edgeValue * -1;
5156
incidenceMatrix[j][edgeBeginning] = edgeValue;
5257
}
@@ -65,6 +70,11 @@ void DirectedGraph::loadRawDataToList(std::vector<int> rawData) {
6570
int edgeEnd = rawData[i++];
6671
int edgeValue = rawData[i++];
6772

73+
if (edgeBeginning == edgeEnd) {
74+
incidenceMatrix.clear();
75+
throw "Petle sa nieakceptowane!";
76+
}
77+
6878
adjacencyList[edgeBeginning].push_front({edgeEnd, edgeValue});
6979
}
7080
}

Graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ vector<int> Graph::loadRawDataFrom(string path) {
137137
fstream file(path, ios::in);
138138

139139
if (!file.is_open())
140-
return returnIntVector; // should throw an error
140+
throw "Plik nie istnieje, badz zablokowany dostep!";
141141

142142
string temp = "";
143143
while (file >> temp) {

UndirectedGraph.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ void UndirectedGraph::loadRawDataToMatrix(vector<int> rawData) {
4747
int edgeEnd = rawData[i++];
4848
int edgeValue = rawData[i++];
4949

50+
if (edgeBeginning == edgeEnd) {
51+
incidenceMatrix.clear();
52+
throw "Petle sa nieakceptowane!";
53+
}
54+
5055
incidenceMatrix[j][edgeEnd] = edgeValue;
5156
incidenceMatrix[j][edgeBeginning] = edgeValue;
5257
}
@@ -65,11 +70,12 @@ void UndirectedGraph::loadRawDataToList(std::vector<int> rawData) {
6570
int edgeEnd = rawData[i++];
6671
int edgeValue = rawData[i++];
6772

68-
adjacencyList[edgeBeginning].push_front({edgeEnd, edgeValue});
69-
70-
if (edgeBeginning == edgeEnd)
71-
continue;
73+
if (edgeBeginning == edgeEnd) {
74+
incidenceMatrix.clear();
75+
throw "Petle sa nieakceptowane!";
76+
}
7277

78+
adjacencyList[edgeBeginning].push_front({edgeEnd, edgeValue});
7379
adjacencyList[edgeEnd].push_front({edgeBeginning, edgeValue});
7480
}
7581
}

0 commit comments

Comments
 (0)