🌺 Node¢

Classes:

Node([name,Β sep])

Node is an extension of BaseNode, and is able to extend to any Python class.

class bigtree.node.node.Node(name: str = '', sep: str = '/', **kwargs: Any)ΒΆ

Bases: BaseNode

Node is an extension of BaseNode, and is able to extend to any Python class. Nodes can have attributes if they are initialized from Node, dictionary, or pandas DataFrame.

Nodes can be linked to each other with parent and children setter methods.

>>> from bigtree import Node
>>> a = Node("a")
>>> b = Node("b")
>>> c = Node("c")
>>> d = Node("d")
>>> b.parent = a
>>> b.children = [c, d]

Directly passing parent argument.

>>> from bigtree import Node
>>> a = Node("a")
>>> b = Node("b", parent=a)
>>> c = Node("c", parent=b)
>>> d = Node("d", parent=b)

Directly passing children argument.

>>> from bigtree import Node
>>> d = Node("d")
>>> c = Node("c")
>>> b = Node("b", children=[c, d])
>>> a = Node("a", children=[b])

Node Creation

Node can be created by instantiating a Node class or by using a dictionary. If node is created with dictionary, all keys of dictionary will be stored as class attributes.

>>> from bigtree import Node
>>> a = Node.from_dict({"name": "a", "age": 90})

Node Attributes

These are node attributes that have getter and/or setter methods.

Get and set Node configuration

  1. sep: Get/set separator for path name

Get Node configuration

  1. node_name: Get node name, without accessing name directly

  2. path_name: Get path name from root, separated by sep

Node Methods

These are methods available to be performed on Node.

Node methods

  1. show(): Print tree to console

  2. hshow(): Print tree in horizontal orientation to console


Methods:

hshow(**kwargs)

Print tree in horizontal orientation to console, takes in same keyword arguments as hprint_tree function

show(**kwargs)

Print tree to console, takes in same keyword arguments as print_tree function

Attributes:

node_name

Get node name

path_name

Get path name, separated by self.sep

sep

Get separator, gets from root node

hshow(**kwargs: Any) β†’ NoneΒΆ

Print tree in horizontal orientation to console, takes in same keyword arguments as hprint_tree function

property node_name: strΒΆ

Get node name

Returns:

(str)

property path_name: strΒΆ

Get path name, separated by self.sep

Returns:

(str)

property sep: strΒΆ

Get separator, gets from root node

Returns:

(str)

show(**kwargs: Any) β†’ NoneΒΆ

Print tree to console, takes in same keyword arguments as print_tree function