Skip to content

Commit 7700223

Browse files
authored
respect canonical flag in SubtreeIterator (#46)
* respect canonical flag in SubtreeIterator * add more tests
1 parent ef96c06 commit 7700223

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/RootedTrees.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,10 @@ end
512512

513513
# find the next complete subtree
514514
subtree_last_index = _subtree_last_index(subtree_root_index, level_sequence)
515-
subtree = RootedTree(view(level_sequence,
516-
subtree_root_index:subtree_last_index))
515+
subtree = RootedTree(
516+
view(level_sequence, subtree_root_index:subtree_last_index),
517+
# if t is in canonical representation, its subtrees are, too
518+
iscanonical(subtrees.t))
517519

518520
return (subtree, subtree_last_index + 1)
519521
end

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ end
246246
@test β(t17) == α(t17)*γ(t17)
247247
@test t17 == t1 t8
248248
@test butcher_representation(t17) == "[[[[τ]]]]"
249+
250+
# test non-canonical representation
251+
level_sequence = [1, 2, 3, 2, 3, 4, 2, 3, 2, 3, 4, 5, 6, 2, 3, 4]
252+
@test σ(rootedtree(level_sequence)) == σ(RootedTrees.RootedTree(level_sequence))
249253
end
250254

251255

0 commit comments

Comments
 (0)