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

Commit 93d4be6

Browse files
committed
Fix Dijkstra's algorithm
1 parent 2f26220 commit 93d4be6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

DirectedGraph.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ std::string DirectedGraph::dijkstrasAlgorithmOnMatrix(int beginVertex, int endVe
177177
unsigned long currentLength = pathLength[currentVertex];
178178

179179
for (auto& row : incidenceMatrix) {
180-
if (row[beginVertex] > 0) {
180+
if (row[currentVertex] > 0) {
181181
for (int j = 0; j < numberOfVertices; j++) {
182182
if (row[j] < 0) {
183-
if (pathLength[j] > currentLength + row[beginVertex]) {
184-
pathLength[j] = currentLength + row[beginVertex];
183+
if (pathLength[j] > currentLength + row[currentVertex]) {
184+
pathLength[j] = currentLength + row[currentVertex];
185185
previousVertex[j] = currentVertex;
186186
}
187187
}

0 commit comments

Comments
 (0)