Skip to content

Commit 491be71

Browse files
authored
Merge pull request #941 from ahmedrezik/Update-Protocols
Updated protocols for Graph Data Structure
2 parents 657a29f + b23f10d commit 491be71

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

Graph/Graph/Edge.swift

+9-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ extension Edge: CustomStringConvertible {
2929

3030
extension Edge: Hashable {
3131

32-
public func hash(into hasher: inout Hasher) {
33-
hasher.combine(from.description)
34-
hasher.combine(to.description)
35-
hasher.combine(weight)
36-
}
32+
public func hash(into hasher: inout Hasher) {
33+
hasher.combine(from)
34+
hasher.combine(to)
35+
if weight != nil {
36+
hasher.combine(weight)
37+
}
38+
}
39+
40+
3741
}
3842

3943
public func == <T>(lhs: Edge<T>, rhs: Edge<T>) -> Bool {

Graph/Graph/Vertex.swift

+10-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ extension Vertex: CustomStringConvertible {
2424

2525
extension Vertex: Hashable {
2626

27-
public func hash(into hasher: inout Hasher) {
28-
hasher.combine(data)
29-
hasher.combine(index)
30-
}
27+
28+
29+
30+
public func hasher(into hasher: inout Hasher){
31+
32+
hasher.combine(data)
33+
hasher.combine(index)
34+
}
35+
36+
3137

3238
}
3339

0 commit comments

Comments
 (0)