Skip to content

Commit 7364263

Browse files
authored
Merge pull request kodecocodes#515 from specialfor/master
Correct typo
2 parents 8a1d712 + e30d68d commit 7364263

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Dijkstra Algorithm/Dijkstra.playground/Sources/Dijkstra.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Dijkstra {
1919
var currentVertex: Vertex? = startVertex
2020
while let vertex = currentVertex {
2121
currentVertices.remove(vertex)
22-
let filteredNeighbors = vertex.neighbors.filter { totalVertices.contains($0.0) }
22+
let filteredNeighbors = vertex.neighbors.filter { currentVertices.contains($0.0) }
2323
for neighbor in filteredNeighbors {
2424
let neighborVertex = neighbor.0
2525
let weight = neighbor.1
@@ -31,11 +31,11 @@ public class Dijkstra {
3131
neighborVertex.pathVerticesFromStart.append(neighborVertex)
3232
}
3333
}
34-
if totalVertices.isEmpty {
34+
if currentVertices.isEmpty {
3535
currentVertex = nil
3636
break
3737
}
38-
currentVertex = totalVertices.min { $0.pathLengthFromStart < $1.pathLengthFromStart }
38+
currentVertex = currentVertices.min { $0.pathLengthFromStart < $1.pathLengthFromStart }
3939
}
4040
}
4141
}

0 commit comments

Comments
 (0)