Bridges-Python 3.5.1
Bridges(Python API)
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
bridges.tree_element.TreeElement Class Reference

This class extends Element to represent general trees with arbitrary number of children. More...

Inheritance diagram for bridges.tree_element.TreeElement:
bridges.element.Element bridges.bin_tree_element.BinTreeElement bridges.bst_element.BSTElement bridges.avl_tree_element.AVLTreeElement bridges.kd_tree_element.KDTreeElement

Public Member Functions

None __init__ (self, **kwargs)
 Constructor for Tree Element.
 
str get_data_structure_type (self)
 Gets the data structure type.
 
None add_child (self, child)
 Adds a child to this parent node.
 
int get_number_of_children (self)
 Get the number of children at this node.
 
None set_child (self, int index, child)
 Adds a child to the node that will be added at the next open position.
 
 get_child (self, int index)
 Gets a child at particular index.
 
dict get_data_structure_representation (self)
 Get the hierarchical JSON of the tree representation (internal use only)
 
- Public Member Functions inherited from bridges.element.Element
LinkVisualizer get_link_visualizer (self, el)
 Getter for the link visualizer object that links this element to another element specified by the argument.
 
None set_link_visualizer (self, el)
 Setter for the link visualizer of this element.
 
None remove_link_visualizer (self, el)
 Deleter function for the lik visualizer of this element.
 
 set_location (self, locX, locY)
 Setter for the element's location.
 
 get_locationX (self)
 Getter for the element's location in X.
 
 get_locationY (self)
 Getter for the element's location in Y.
 
 get_element_representation (self)
 Getter for the element's JSON representation (for internal use)
 
 get_link_representation (self, lv, src, dest)
 Getter for the JSON representation of the element's link (for internal use)
 

Public Attributes

 children
 

Static Public Attributes

str QUOTE = "\""
 
str COMMA = ","
 
str COLON = ":"
 
str OPEN_CURLY = "{"
 
str CLOSE_CURLY = "}"
 
str OPEN_PAREN = "("
 
str CLOSE_PAREN = ")"
 
str OPEN_BOX = "["
 
str CLOSE_BOX = "]"
 
- Static Public Attributes inherited from bridges.element.Element
int ids = 0
 

Protected Member Functions

dict _pre_order (self, root)
 Use a preoreder traversal to directly extract a hierarchical JSON representation of the tree.
 

Additional Inherited Members

- Protected Attributes inherited from bridges.element.Element
 _link_visualizer
 
 _ids
 
 _identifier
 
 _visualizer
 
 _value
 
 _label
 
- Properties inherited from bridges.element.Element
 value = property
 Getter for the value this element is holding.
 
 identifier = property
 Getter for the element identifier.
 
 visualizer = property
 Getter for the element visualizer.
 
 label = property
 Getter for the element's label.
 
 size = property
 Getter for the element's size.
 
 color = property
 Getter for the element's color.
 
 opacity = property
 Getter for the element's opacity.
 
 shape = property
 Getter for the element's shape type.
 
 id = property
 Get numer of ids of element object.
 

Detailed Description

This class extends Element to represent general trees with arbitrary number of children.

TreeElement nodes can have an arbitrary number of child nodes(held in in a vector in the order in which they were added). The visualization of trees assumes that the children are drawn in order from left to right.

Tree Elements have labels (string) that are displayed on the visualization. Elements take an generic object E as a user defined parameter, which can be any native type or object.

Elements contain a visualizer (ElementVisualizer) object for setting visual attributes (color, shape, opacity, size), necessary for displaying them in a web browser.

Elements also have a LinkVisualizer object that is used when they are linked to another element, appropriate for setting link attributes, between parent and child nodes.

Author
Matthew McQuaigue
Date
2018, 7/23/19
See also
Kd tree tutorial https://bridgesuncc.github.io/tutorials/KdTree.html

Constructor & Destructor Documentation

◆ __init__()

None bridges.tree_element.TreeElement.__init__ (   self,
**  kwargs 
)

Constructor for Tree Element.

       (0): The label for the tree element that shows in visualization
       (1): the generic object 'e' that the tree element will hold
       (2): the tree element assigned to child 0
       (3): the tree element assigned to child 1
Returns
None

Reimplemented from bridges.element.Element.

Reimplemented in bridges.bin_tree_element.BinTreeElement, bridges.bst_element.BSTElement, bridges.kd_tree_element.KDTreeElement, and bridges.avl_tree_element.AVLTreeElement.

Member Function Documentation

◆ _pre_order()

dict bridges.tree_element.TreeElement._pre_order (   self,
  root 
)
protected

Use a preoreder traversal to directly extract a hierarchical JSON representation of the tree.

Parameters
rootthe root of the tree structure
Returns
dict representing the json to be returned

◆ add_child()

None bridges.tree_element.TreeElement.add_child (   self,
  child 
)

Adds a child to this parent node.

Parameters
childthe child node to add
Returns
None

◆ get_child()

bridges.tree_element.TreeElement.get_child (   self,
int  index 
)

Gets a child at particular index.

Parameters
indexindex to get child
Returns
the child element at this index
Exceptions
ValueErrorif the index is higher than the number of children

◆ get_data_structure_representation()

dict bridges.tree_element.TreeElement.get_data_structure_representation (   self)

Get the hierarchical JSON of the tree representation (internal use only)

Returns
dict representing the data structures json

◆ get_data_structure_type()

str bridges.tree_element.TreeElement.get_data_structure_type (   self)

Gets the data structure type.

Returns
str representing the data structure type

Reimplemented from bridges.element.Element.

Reimplemented in bridges.avl_tree_element.AVLTreeElement, bridges.bin_tree_element.BinTreeElement, bridges.bst_element.BSTElement, and bridges.kd_tree_element.KDTreeElement.

◆ get_number_of_children()

int bridges.tree_element.TreeElement.get_number_of_children (   self)

Get the number of children at this node.

Returns
int representing the number of children

◆ set_child()

None bridges.tree_element.TreeElement.set_child (   self,
int  index,
  child 
)

Adds a child to the node that will be added at the next open position.

Parameters
indexindex to add child
childchild to add to tree
Returns
None
Exceptions
ValueErrorIf the index is higher than the number of children

Member Data Documentation

◆ children

bridges.tree_element.TreeElement.children

◆ CLOSE_BOX

str bridges.tree_element.TreeElement.CLOSE_BOX = "]"
static

◆ CLOSE_CURLY

str bridges.tree_element.TreeElement.CLOSE_CURLY = "}"
static

◆ CLOSE_PAREN

str bridges.tree_element.TreeElement.CLOSE_PAREN = ")"
static

◆ COLON

str bridges.tree_element.TreeElement.COLON = ":"
static

◆ COMMA

str bridges.tree_element.TreeElement.COMMA = ","
static

◆ OPEN_BOX

str bridges.tree_element.TreeElement.OPEN_BOX = "["
static

◆ OPEN_CURLY

str bridges.tree_element.TreeElement.OPEN_CURLY = "{"
static

◆ OPEN_PAREN

str bridges.tree_element.TreeElement.OPEN_PAREN = "("
static

◆ QUOTE

str bridges.tree_element.TreeElement.QUOTE = "\""
static

The documentation for this class was generated from the following file: