We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3e301e8 commit 0a813baCopy full SHA for 0a813ba
Dijkstra Algorithm/Dijkstra.playground/Sources/Dijkstra.swift
@@ -13,11 +13,12 @@ public class Dijkstra {
13
14
public func findShortestPaths(from startVertex: Vertex) {
15
clearCache()
16
+ var currentVertices = self.totalVertices
17
startVertex.pathLengthFromStart = 0
18
startVertex.pathVerticesFromStart.append(startVertex)
19
var currentVertex: Vertex? = startVertex
20
while let vertex = currentVertex {
- totalVertices.remove(vertex)
21
+ currentVertices.remove(vertex)
22
let filteredNeighbors = vertex.neighbors.filter { totalVertices.contains($0.0) }
23
for neighbor in filteredNeighbors {
24
let neighborVertex = neighbor.0
0 commit comments