Skip to content

Commit 47ffb0e

Browse files
committed
hash for ValEdge and ValDiEdge
1 parent c0e1da7 commit 47ffb0e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/SimpleValueGraphs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import LightGraphs:
2222
adjacency_matrix
2323

2424
import Base: show, iterate, length,
25-
getindex, size, ==
25+
getindex, size, ==, hash
2626

2727
import LinearAlgebra
2828
import LinearAlgebra:
@@ -97,6 +97,7 @@ export
9797
show,
9898
zero,
9999
==,
100+
hash,
100101

101102
# overridden methods from LinearAlgebra
102103
ishermitian,

src/valueedge.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,13 @@ LG.is_directed(e::AbstractValEdge) = is_directed(typeof(e))
180180
# ------------------------------------------------------
181181

182182
==(lhs::ValEdge, rhs::ValEdge) =
183-
lhs.src == rhs.src && lhs.dst == lhs.dst && lhs.values == rhs.values
183+
lhs.src == rhs.src && lhs.dst == rhs.dst && lhs.values == rhs.values
184184

185185
==(lhs::ValDiEdge, rhs::ValDiEdge) =
186-
lhs.src == rhs.src && lhs.dst == lhs.dst && lhs.values == rhs.values
186+
lhs.src == rhs.src && lhs.dst == rhs.dst && lhs.values == rhs.values
187187

188+
hash(e::ValEdge, h::UInt) = hash(e.src, hash(e.dst, hash(e.values, h)))
189+
hash(e::ValDiEdge, h::UInt) = hash(e.src, hash(e.dst, hash(e.values, h)))
188190

189191
# ======================================================
190192
# show

0 commit comments

Comments
 (0)