πΊ NodeΒΆ
Classes:
|
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:
BaseNodeNode 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
sep: Get/set separator for path name
Get Node configuration
node_name: Get node name, without accessing name directlypath_name: Get path name from root, separated by sep
Node Methods
These are methods available to be performed on Node.
Node methods
show(): Print tree to console
Attributes:
Get node name
Get path name, separated by self.sep
Get separator, gets from root node
Methods:
show(**kwargs)Print tree to console, takes in same keyword arguments as print_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