ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 07 Sep 2016 15:34:32 +0200DyckWords: workaround for from_ordered_tree?https://ask.sagemath.org/question/34763/dyckwords-workaround-for-from_ordered_tree/** MuPAD-Combinat knows (according to the docs)
for Dyck words the canonical bijection from
ordered trees with n+1 nodes to Dyck words of size n such that if a tree
t has t_1,...,t_k as childs then f(t) = [1,f(t_1),0,...,1,f(t_k),0].
* fromOrderedTree
– canonical bijection from ordered trees to Dyck words
combinat::dyckWords::fromOrderedTree(ordered tree t)
Returns the Dyck word corresponding to the ordered tree t.
* toOrderedTree
– canonical bijection from Dyck words to ordered trees
combinat::dyckWords::toOrderedTree(Dyck word w)
Returns the ordered tree corresponding to the Dyck word w.
** SageMath-Combinat knows
* to_ordered_tree()
* from_ordered_tree() NotImplementedError: TODO
What a pitty! My question is: What is a quick workaround for this missing function?
EDIT:
Since it is so easy as tmontail in his answer shows then I do not
understand why it is not implemented. At least a hint in the docs
seems appropriate.Wed, 07 Sep 2016 12:18:22 +0200https://ask.sagemath.org/question/34763/dyckwords-workaround-for-from_ordered_tree/Answer by tmonteil for <p>** MuPAD-Combinat knows (according to the docs) </p>
<p>for Dyck words the canonical bijection from
ordered trees with n+1 nodes to Dyck words of size n such that if a tree
t has t_1,...,t_k as childs then f(t) = [1,f(t_1),0,...,1,f(t_k),0].</p>
<ul>
<li>fromOrderedTree </li>
</ul>
<p>– canonical bijection from ordered trees to Dyck words
combinat::dyckWords::fromOrderedTree(ordered tree t)
Returns the Dyck word corresponding to the ordered tree t.</p>
<ul>
<li>toOrderedTree</li>
</ul>
<p>– canonical bijection from Dyck words to ordered trees
combinat::dyckWords::toOrderedTree(Dyck word w)
Returns the ordered tree corresponding to the Dyck word w.</p>
<p>** SageMath-Combinat knows</p>
<ul>
<li><p>to_ordered_tree()</p></li>
<li><p>from_ordered_tree() NotImplementedError: TODO</p></li>
</ul>
<p>What a pitty! My question is: What is a quick workaround for this missing function?</p>
<p>EDIT:
Since it is so easy as tmontail in his answer shows then I do not
understand why it is not implemented. At least a hint in the docs
seems appropriate.</p>
https://ask.sagemath.org/question/34763/dyckwords-workaround-for-from_ordered_tree/?answer=34764#post-id-34764Given an ordered tree `T`, you can do:
sage: T.to_dyck_word()
Wed, 07 Sep 2016 15:34:32 +0200https://ask.sagemath.org/question/34763/dyckwords-workaround-for-from_ordered_tree/?answer=34764#post-id-34764