Skip to content

Commit 6972d35

Browse files
sbeitzelCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent 5cca945 commit 6972d35

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/SwiftGraph/Graph.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,13 @@ extension Graph {
317317
/// - parameter fromIndex: The index of the starting vertex.
318318
/// - parameter toIndex: The index of the ending vertex.
319319
/// - returns: `true` if a path exists
320-
func pathExists(fromIndex: Int, toIndex: Int) -> Bool {
320+
public func pathExists(fromIndex: Int, toIndex: Int) -> Bool {
321321
var visited: [Bool] = [Bool](repeating: false, count: vertexCount)
322322
var stack: [Int] = []
323323
stack.append(fromIndex)
324324
while !stack.isEmpty {
325-
if let v: Int = stack.popLast() {
326-
if (visited[v]) {
325+
if let v = stack.popLast() {
326+
if visited[v] {
327327
continue
328328
}
329329
visited[v] = true
@@ -347,7 +347,7 @@ extension Graph {
347347
/// - parameter toIndex: the index of the destination vertex
348348
/// - parameter visited: a set of vertex indices which will be considered to have been visited already
349349
/// - returns: the number of paths that exist going from the start to the destinatin
350-
func countPaths(fromIndex startIndex: Int, toIndex endIndex: Int, visited: inout Set<Int>) -> Int {
350+
public func countPaths(fromIndex startIndex: Int, toIndex endIndex: Int, visited: inout Set<Int>) -> Int {
351351
if startIndex == endIndex { return 1 }
352352
visited.insert(startIndex)
353353
var total = 0
@@ -382,7 +382,7 @@ extension Graph {
382382
}
383383

384384
/// Computes whether or not a given vertex (by index) is reachable, for every vertex in the graph.
385-
func reachabilityOf(_ index: Int) -> [Int: Bool] {
385+
public func reachabilityOf(_ index: Int) -> [Int: Bool] {
386386
var answers: [Int: Bool] = [:]
387387
for vi in vertices.indices {
388388
answers[vi] = pathExists(fromIndex: vi, toIndex: index)

Tests/SwiftGraphTests/SwiftGraphTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class SwiftGraphTests: XCTestCase {
150150
XCTFail("Bad graph, no out")
151151
return
152152
}
153-
guard let svrIndex = graph.indexOfVertex( "svr" ) else {
153+
guard let svrIndex = graph.indexOfVertex("svr") else {
154154
XCTFail("Bad graph, no svr")
155155
return
156156
}

0 commit comments

Comments
 (0)