File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,14 @@ impl<'treeseq> LLTree<'treeseq> {
144144 Ok ( NodeIteratorAdapter ( SamplesIterator :: new ( self , u) ?) )
145145 }
146146
147+ pub fn parent ( & self , u : NodeId ) -> Option < NodeId > {
148+ super :: tsk_column_access :: < NodeId , _ , _ , _ > (
149+ u,
150+ self . as_ref ( ) . parent ,
151+ self . treeseq . num_nodes_raw ( ) + 1 ,
152+ )
153+ }
154+
147155 pub fn flags ( & self ) -> TreeFlags {
148156 self . flags
149157 }
Original file line number Diff line number Diff line change @@ -139,6 +139,13 @@ impl<'treeseq> Tree<'treeseq> {
139139 pub fn flags ( & self ) -> TreeFlags {
140140 self . inner . flags ( )
141141 }
142+
143+ /// Get the parent of node `u`.
144+ ///
145+ /// Returns `None` if `u` is out of range.
146+ pub fn parent < N : Into < NodeId > + Copy + std:: fmt:: Debug > ( & self , u : N ) -> Option < NodeId > {
147+ self . inner . parent ( u. into ( ) )
148+ }
142149}
143150
144151impl < ' ts > streaming_iterator:: StreamingIterator for Tree < ' ts > {
You can’t perform that action at this time.
0 commit comments