Skip to content

Commit a0a73a8

Browse files
VEZYbspanoghe
andcommitted
Reparent the child nodes
Co-Authored-By: bspanoghe <70662421+bspanoghe@users.noreply.github.com>
1 parent 9878460 commit a0a73a8

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/compute_MTG/insert_nodes.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ function insert_generation!(node::Node{N,A}, template, attr_fun=node -> A(), max
363363
# Add the new node as the only child of the node:
364364
rechildren!(node, Node{N,A}[new_node])
365365

366+
# Add the new node as parent of the children
367+
for chnode in children(new_node)
368+
reparent!(chnode, new_node)
369+
end
370+
366371
return node
367372
end
368373

test/test-insert_node.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ end
123123
insert_generation!(mtg_orig[1], template)
124124

125125
@test length(mtg) == length(mtg_orig)
126-
@test mtg_orig[1][1] == mtg_orig[1][1]
126+
@test mtg[1][2] == mtg_orig[1][1]
127+
128+
parent(get_node(mtg_orig, 8)) == mtg_orig[1]
129+
parent(get_node(mtg_orig, 3)) == get_node(mtg_orig, 8)
130+
children(get_node(mtg_orig, 2))[1] == get_node(mtg_orig, 8)
127131
end
128132

129133
@testset "test insert_generations!" begin

0 commit comments

Comments
 (0)