Skip to content

Commit

Permalink
Merge pull request #2 from jarbus/master
Browse files Browse the repository at this point in the history
rem_vertex! bugfix
  • Loading branch information
matbesancon authored Oct 29, 2021
2 parents 97a42ed + bd6a8bd commit 7af5d1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/MetaGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ function rem_vertex!(g::AbstractMetaGraph, v::Integer)
set_prop!(g, v, key, val)
end
end

# Map property keys to new node values
if lastv in keys(lasteoutprops)
lasteoutprops[v] = lasteoutprops[lastv]
delete!(lasteoutprops, lastv)
end
if lastv in keys(lasteinprops)
lasteinprops[v] = lasteinprops[lastv]
delete!(lasteinprops, lastv)
end

for n in outneighbors(g, v)
set_props!(g, v, n, lasteoutprops[n])
end
Expand Down
6 changes: 6 additions & 0 deletions test/metagraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,12 @@ import Base64:
@test get_prop(mga, 5, :prop) == "node5"
@test get_prop(mga, 1, :prop) == "newnode1"

# test for 87
mdg = MetaDiGraph(2)
add_edge!(mdg, 2, 2)
rem_vertex!(mdg, 1)
@test neighbors(mdg, 1) == [1]
@test nv(mdg) == 1

end

Expand Down

0 comments on commit 7af5d1a

Please sign in to comment.