diff --git a/Graph/Graph/Edge.swift b/Graph/Graph/Edge.swift index b69937895..3c95f9666 100644 --- a/Graph/Graph/Edge.swift +++ b/Graph/Graph/Edge.swift @@ -29,11 +29,15 @@ extension Edge: CustomStringConvertible { extension Edge: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(from.description) - hasher.combine(to.description) - hasher.combine(weight) - } + public func hash(into hasher: inout Hasher) { + hasher.combine(from) + hasher.combine(to) + if weight != nil { + hasher.combine(weight) + } + } + + } public func == (lhs: Edge, rhs: Edge) -> Bool { diff --git a/Graph/Graph/Vertex.swift b/Graph/Graph/Vertex.swift index 47499dcc6..f74b38396 100644 --- a/Graph/Graph/Vertex.swift +++ b/Graph/Graph/Vertex.swift @@ -24,10 +24,16 @@ extension Vertex: CustomStringConvertible { extension Vertex: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(data) - hasher.combine(index) - } + + + + public func hasher(into hasher: inout Hasher){ + + hasher.combine(data) + hasher.combine(index) + } + + }