From 073cd69fb9a013bce76849b41e6f9f859336d390 Mon Sep 17 00:00:00 2001 From: jarbus Date: Fri, 1 Oct 2021 16:08:44 -0400 Subject: [PATCH 1/2] rem_vertex! bugfix Resolves an issue where properties that point from the last node to the last node don't get updated with the new vertex number --- src/MetaGraphs.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/MetaGraphs.jl b/src/MetaGraphs.jl index e3ef01e..abf54d1 100644 --- a/src/MetaGraphs.jl +++ b/src/MetaGraphs.jl @@ -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 From bd6a8bdc35ad06a4ad5479f06a6dc1fc789d6c79 Mon Sep 17 00:00:00 2001 From: jarbus Date: Fri, 1 Oct 2021 18:15:22 -0400 Subject: [PATCH 2/2] adding test for #87 --- test/metagraphs.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/metagraphs.jl b/test/metagraphs.jl index 7de7bd1..2e9c38e 100644 --- a/test/metagraphs.jl +++ b/test/metagraphs.jl @@ -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