davecom / SwiftGraph

A Graph Data Structure in Pure Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

removeAllEdges crash

ProudOfZiggy opened this issue · comments

Calling
public func removeAllEdges(from: V, to: V, bidirectional: Bool = true)
crashes at calling
public func removeAllEdges(from: Int, to: Int, bidirectional: Bool = true)
with fatal error: Index out of range

I think it's because you are removing elements from array in wrong way.

Hi @ProudOfZiggy,

Please provide sample code that causes the crash.

Here you go:

let graph = UnweightedGraph(vertices: ["1", "2", "3", "4", "5", "6"])

graph.addEdge(from: 0, to: 1, directed: false)
graph.addEdge(from: 1, to: 2, directed: false)
graph.addEdge(from: 2, to: 3, directed: false)
graph.addEdge(from: 3, to: 4, directed: false)
graph.addEdge(from: 4, to: 5, directed: false)
        
graph.removeAllEdges(from: "2", to: "3")

Thanks for reporting this issue. I'll submit a fix shortly.

Thank you. Will wait for a pods specs update.

Fixed in SwiftGraph 1.4.1