Skip to content

Commit 8841111

Browse files
committed
type indication for adjusted mintype, tests empty constructor
1 parent 77065c0 commit 8841111

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/staticdigraph.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424
ne(g::StaticDiGraph{T, U}) where T where U = U(length(g.f_vec))
2525

2626
# sorted src, dst vectors for forward and backward edgelists.
27-
function StaticDiGraph(nvtx::I, f_ss::AbstractVector, f_ds::AbstractVector, b_ss::AbstractVector, b_ds::AbstractVector) where {I<:Integer}
27+
function StaticDiGraph(nvtx::I, f_ss::AbstractVector{F}, f_ds::AbstractVector{D}, b_ss::AbstractVector{B}, b_ds::AbstractVector{S}) where {I<:Integer,S<:Integer,D<:Integer,B<:Integer,F<:Integer}
2828
length(f_ss) == length(f_ds) == length(b_ss) == length(b_ds) || error("source and destination vectors must be equal length")
2929
(nvtx == 0 || length(f_ss) == 0) && return StaticDiGraph(UInt8[], UInt8[1], UInt8[], UInt8[1])
3030
f_ind = [searchsortedfirst(f_ss, x) for x in 1:nvtx]

src/staticgraph.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct StaticGraph{T<:Integer, U<:Integer} <: AbstractStaticGraph{T, U}
1111
end
1212

1313
# sorted src, dst vectors
14-
# note: this requires reverse edges included in the sorted vector.
15-
function StaticGraph(nvtx::I, ss::AbstractVector, ds::AbstractVector) where {I<:Integer}
14+
# note: this requires reverse edges included in the sorted vector.
15+
function StaticGraph(nvtx::I, ss::AbstractVector{S}, ds::AbstractVector{D}) where {I<:Integer,S<:Integer,D<:Integer}
1616
length(ss) != length(ds) && error("source and destination vectors must be equal length")
1717
(nvtx == 0 || length(ss) == 0) && return StaticGraph()
1818
f_ind = [searchsortedfirst(ss, x) for x in 1:nvtx]
@@ -29,7 +29,7 @@ function StaticGraph(nvtx::I, sd::Vector{Tuple{T, T}}) where {T<:Integer, I<:Int
2929
return StaticGraph(nvtx, ss, ds)
3030
end
3131

32-
function StaticGraph(g::LightGraphs.SimpleGraphs.SimpleGraph)
32+
function StaticGraph(g::LightGraphs.SimpleGraph)
3333
sd1 = [Tuple(e) for e in edges(g)]
3434
ds1 = [Tuple(reverse(e)) for e in edges(g)]
3535
sd = sort(vcat(sd1, ds1))

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const testdir = dirname(@__FILE__)
1717
gu = squash(g)
1818
sg = StaticGraph(g)
1919
sgu = StaticGraph(gu)
20+
gempty = StaticGraph()
2021
@test sprint(show, sg) == "{5, 6} undirected simple static {UInt8, UInt8} graph"
2122
@test sprint(show, sgu) == "{5, 6} undirected simple static {UInt8, UInt8} graph"
2223
testfn(fn, args...) =
@@ -49,6 +50,9 @@ const testdir = dirname(@__FILE__)
4950
@test @inferred !is_directed(hu)
5051
@test @inferred !is_directed(StaticGraph)
5152
@test @inferred collect(edges(hu)) == collect(edges(sg))
53+
@test nv(gempty) == 0
54+
@test typeof(LightGraphs.nv(gempty)) == UInt8
55+
@test length(LightGraphs.edges(gempty)) === 0x00
5256
end # staticgraph
5357

5458
@testset "staticdigraph" begin

0 commit comments

Comments
 (0)