Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return correct type add_vertex! and add_vertices! #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/abstract_multigraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ rem_edge!(mg::AbstractMultigraph, x, y, z) = rem_edge!(mg, MultipleEdge(x, y, z)

has_vertex(mg::AbstractMultigraph, v::Integer) = v in vertices(mg)
rem_vertex!(mg::AbstractMultigraph{T}, v::T) where {T<:Integer} = rem_vertices!(mg, [v])
add_vertex!(mg::AbstractMultigraph{T}) where {T<:Integer} = add_vertices!(mg, one(T))
add_vertex!(mg::AbstractMultigraph{T}) where {T<:Integer} = add_vertices!(mg, one(T)) == 1 ? true : false

function outneighbors(mg::AbstractMultigraph, v) end
function inneighbors(mg::AbstractMultigraph, v) end
Expand Down
2 changes: 1 addition & 1 deletion src/multigraph_adjlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function add_vertices!(mg::Multigraph{T}, n::Integer) where {T<:Integer}
for i in new_ids
mg.adjlist[i] = T[]
end
return new_ids
return length(new_ids)
end

function outneighbors(mg::Multigraph, v::Integer; count_mul::Bool = false)
Expand Down
6 changes: 5 additions & 1 deletion test/multigraph_adjlist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ add_vertex!(g)
@test indegree(g) == outdegree(g)

mg0 = Multigraph(0)
@test nv(mg0) == ne(mg0) == 0
@test nv(mg0) == ne(mg0) == 0
# addvertex returns correct type
@test add_vertex!(mg0)
@test add_vertices!(mg0, 5) == 5