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
3 changes: 3 additions & 0 deletions src/di_multigraph_adjlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function DiMultigraph(adjmx::AbstractMatrix{U}) where {U<:Integer}
end
DiMultigraph{Int}(adjlist, m)
end
DiMultigraph() = DiMultigraph(0)
DiMultigraph{T}() where T = DiMultigraph(0)
DiMultigraph{T}(t::T) where T = DiMultigraph(t)
function DiMultigraph(n::T) where {T<:Integer}
n >= 0 || error("Number of vertices should be non-negative")
adjlist = Dict{T, Vector{T}}()
Expand Down
3 changes: 3 additions & 0 deletions src/multigraph_adjlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function Multigraph(adjmx::AbstractMatrix{U}) where {U<:Integer}
end
Multigraph{Int}(adjlist, m)
end
Multigraph() = Multigraph(0)
Multigraph{T}() where T = Multigraph(0)
Multigraph{T}(t::T) where T = Multigraph(t)
function Multigraph(n::T) where {T<:Integer}
n >= 0 || error("Number of vertices should be non-negative")
adjlist = Dict{T, Vector{T}}()
Expand Down
9 changes: 8 additions & 1 deletion test/di_multigraph_adjlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,11 @@ add_vertex!(g)
@test indegree(g) != outdegree(g)

dmg0 = DiMultigraph(0)
@test nv(dmg0) == ne(dmg0) == 0
@test nv(dmg0) == ne(dmg0) == 0

#test constructor
@test try DiMultigraph(1); true; catch; false; end
@test try DiMultigraph{Int}(1); true; catch; false; end
@test try DiMultigraph(); true; catch; false; end
@test try DiMultigraph{Int}(); true; catch; false; end

9 changes: 8 additions & 1 deletion test/multigraph_adjlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ add_vertex!(g)
@test indegree(g) == outdegree(g)

mg0 = Multigraph(0)
@test nv(mg0) == ne(mg0) == 0
@test nv(mg0) == ne(mg0) == 0

#test constructor
@test try Multigraph(1); true; catch; false; end
@test try Multigraph{Int}(1); true; catch; false; end
@test try Multigraph(); true; catch; false; end
@test try Multigraph{Int}(); true; catch; false; end