Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
tolerance in spectral
Browse files Browse the repository at this point in the history
  • Loading branch information
sbromberger committed Mar 10, 2017
1 parent 42daf7c commit 567b4f8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
41 changes: 41 additions & 0 deletions benchmarks/core.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
bg = BenchmarkGroup()
SUITE["core"] = bg

function bench_iteredges(g::AbstractGraph)
i = 0
for e in edges(g)
i += 1
end
return i
end

function bench_has_edge(g::AbstractGraph)
srand(1)
nvg = nv(g)
srcs = rand([1:nvg;], cld(nvg, 4))
dsts = rand([1:nvg;], cld(nvg, 4))
i = 0
for (s, d) in zip(srcs, dsts)
if has_edge(g, s, d)
i += 1
end
end
return i
end


EDGEFNS = [
bench_iteredges,
bench_has_edge
]

for fun in EDGEFNS
for (name, g) in GRAPHS
bg["edges","$fun","graph","$name"] = @benchmarkable $fun($g)
end

for (name, g) in DIGRAPHS
bg["edges","$fun","digraph","$name"] = @benchmarkable $fun($g)
end

end
6 changes: 3 additions & 3 deletions test/linalg/spectral.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ full(nbt::Nonbacktracking) = full(sparse(nbt))
@test full(B₁) == full(B)
@test B₁ * ones(size(B₁)[2]) == B*ones(size(B)[2])
@test size(B₁) == size(B)
@test norm(eigs(B₁)[1] - eigs(B)[1]) 0.0 atol=1e-8
@test norm(eigs(B₁)[1] - eigs(B)[1]) 0.0 atol=1e-5
@test !issymmetric(B₁)
@test eltype(B₁) == Float64
# END tests for Nonbacktracking

# spectral distance checks
for n=3:10
polygon = random_regular_graph(n, 2)
@test isapprox(spectral_distance(polygon, polygon), 0, atol=1e-8)
@test isapprox(spectral_distance(polygon, polygon, 1), 0, atol=1e-8)
@test spectral_distance(polygon, polygon) 0 atol=1e-8
@test spectral_distance(polygon, polygon, 1) 0 atol=1e-8
end

0 comments on commit 567b4f8

Please sign in to comment.