Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/abstractnautygraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ Graphs.induced_subgraph(g::AbstractNautyGraph, iter::AbstractVector{<:AbstractEd

Graphs.add_edge!(g::AbstractNautyGraph, i::Integer, j::Integer) = Graphs.add_edge!(g, edgetype(g)(i, j))
Graphs.rem_edge!(g::AbstractNautyGraph, i::Integer, j::Integer) = Graphs.rem_edge!(g, edgetype(g)(i, j))

function Base.hash(edgeiter::SimpleEdgeIter{<:AbstractNautyGraph}, h::UInt)
for edge in edgeiter
h = hash(edge, h)
end
return h
end
6 changes: 0 additions & 6 deletions src/sparsenautygraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,6 @@ function Base.:(==)(e1::SimpleEdgeIter{<:DenseNautyGraph}, e2::SimpleEdgeIter{<:
return true
end
Base.:(==)(e1::SimpleEdgeIter{<:SparseNautyGraph}, e2::SimpleEdgeIter{<:DenseNautyGraph}) = e2 == e1
function Base.hash(edgeiter::SimpleEdgeIter{<:SparseNautyGraph}, h::UInt=zero(UInt))
for edge in edgeiter
h = hash(edge, h)
end
return h
end

Graphs.is_directed(::SparseNautyGraph{D}) where {D} = D
Graphs.is_directed(::Type{SparseNautyGraph{D}}) where {D} = D
Expand Down
6 changes: 6 additions & 0 deletions test/nautygraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ end
@test ne(h) == ne(g)
@test nv(h) == nv(g)
@test edges(h) == edges(g)
@test hash(edges(h)) == hash(edges(g))
@test vertices(h) == vertices(g)
@test labels(h) == labels(g)
@test h._labels !== g._labels
Expand Down Expand Up @@ -494,8 +495,11 @@ end
0 0 0 0]
for (g0, g, sg) in testgraphcollection([A])
@test edges(g) == edges(g0)
# @test hash(edges(g)) == hash(edges(g0))
@test edges(sg) == edges(g0)
# @test hash(edges(sg)) == hash(edges(g0))
@test edges(g) == edges(sg)
@test hash(edges(g)) == hash(edges(sg))

g1 = copy(g0)
add_edge!(g1, 1, nv(g1))
Expand Down Expand Up @@ -536,6 +540,8 @@ end
add_vertex!(sg)
add_edge!(g, nv(g), nv(g))
@test edges(g) != edges(sg)
@test hash(edges(g)) != hash(edges(sg))


add_edge!(sg, nv(g), nv(g))
@test edges(g) == edges(sg)
Expand Down
Loading