skbio.tree.TreeNode.accumulate_to_ancestor¶
- TreeNode.accumulate_to_ancestor(ancestor)[源代码]¶
返回自己与祖先的距离之和
状态:从0.4.0开始实验。
- 参数:
ancestor (TreeNode) -- 祖先的节点也要积累距离
- 返回:
自我与祖先之间的长度之和
- 返回类型:
float
- 抛出:
NoParentError -- 如果祖先不是自己的祖先,就不会产生恐怖
NoLengthError -- 如果self和祖先(包括self)之间的某个节点缺少 length 属性
参见
示例
>>> from skbio import TreeNode >>> tree = TreeNode.read(["((a:1,b:2)c:3,(d:4,e:5)f:6)root;"]) >>> root = tree >>> tree.find('a').accumulate_to_ancestor(root) 4.0