Package logilab :: Package common :: Module tree :: Class Node

[frames] | no frames]

# Class Node

source code

    object --+
             |
            Node

    a basic tree node, characterized by an id

Instance Methods

__init__(self, nid=None) x.__init__(...) initializes x; see help(type(x)) for signature | source code

__iter__(self) | source code

__str__(self, indent=0) str(x) | source code

is_leaf(self) | source code

append(self, child) add a node to children | source code

remove(self, child) remove a child node | source code

insert(self, index, child) insert a child node | source code

replace(self, old_child, new_child) replace a child node with another | source code

get_sibling(self, nid) return the sibling node that has given id | source code

next_sibling(self) return the next sibling for this node if any | source code

previous_sibling(self) return the previous sibling for this node if any | source code

get_node_by_id(self, nid) return node in whole hierarchy that has given id | source code

get_child_by_id(self, nid, recurse=None) return child of given id | source code

get_child_by_path(self, path) return child of given path (path is a list of ids) | source code

depth(self) return depth of this node in the tree | source code

depth_down(self) return depth of the tree from this node | source code

width(self) return the width of the tree from this node | source code

root(self) return the root node of the tree | source code

leaves(self) return a list with all the leaves nodes descendant from this node | source code

flatten(self, _list=None) return a list with all the nodes descendant from this node | source code

lineage(self) return list of parents up to root node | source code

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, nid=None)
(Constructor)

source code

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
  (inherited documentation)

### __str__(self, indent=0)
(Informal representation operator)

source code

str(x)

Overrides: object.__str__
  (inherited documentation)