Skip to content

Commit

Permalink
Fix + test to rem_vertex (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
pw0908 authored Sep 25, 2024
1 parent fb4bb81 commit 5cc8c18
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/model/molgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function rem_vertex!(mol::MolGraph, v::Integer)
delete!(mol.vprops, nv_)
for e in edges_
(src(e) == v || dst(e) == v) && delete!(mol.eprops, e)
((src(e) == v && dst(e) == nv_) || (src(e) == nv_ && dst(e) == v)) && continue
nv_ == v && continue
src(e) == nv_ && begin mol.eprops[u_edge(mol, v, dst(e))] = mol.eprops[e]; delete!(mol.eprops, e) end
dst(e) == nv_ && begin mol.eprops[u_edge(mol, src(e), v)] = mol.eprops[e]; delete!(mol.eprops, e) end
Expand Down
1 change: 1 addition & 0 deletions test/model/molgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ end
@test degree(mol.graph, 3) == 1
@test issetequal(keys(mol.vprops), collect(1:3))
@test issetequal(keys(mol.eprops), Edge.([(1, 2), (2, 3)]))
@test rem_vertex!(mol, 2) # C.C

# Vertex re-ordering when vertices/edges are removed
mol = MolGraph(
Expand Down

0 comments on commit 5cc8c18

Please sign in to comment.