Skip to content

Commit

Permalink
Simplify vertex removal code
Browse files Browse the repository at this point in the history
  • Loading branch information
emstoudenmire committed May 28, 2024
1 parent 6267636 commit 325f2dc
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/steiner_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ using SimpleTraits: SimpleTraits, Not, @traitfn
map(v -> vertex_positions(g)[v], term_vert),
dist_matrix_to_position_dist_matrix(g, distmx),
)
named_st = typeof(g)(
position_tree, map(v -> ordered_vertices(g)[v], vertices(position_tree))
)
# Detect and remove vertices of degree zero
zero_verts = filter(v -> degree(named_st, v) == 0, vertices(named_st))
for v in zero_verts
rem_vertex!(named_st, v)
tree = typeof(g)(position_tree, map(v -> ordered_vertices(g)[v], vertices(position_tree)))
for v in copy(vertices(tree))
iszero(degree(tree, v)) && rem_vertex!(tree, v)
end
return named_st
return tree
end

0 comments on commit 325f2dc

Please sign in to comment.