Bridges-Python-3.0.2  3.0.2
Bridges(PythonAPI)
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
bridges.tree_element.TreeElement Class Reference
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

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 http://bridgesuncc.github.io/tutorials/Tree.html

Public Member Functions

def __init__ (self, kwargs)
 Constructor for Tree Element. More...
 
def get_data_structure_type (self)
 Gets the data structure type. More...
 
def add_child (self, child)
 Adds a child to this parent node. More...
 
def get_number_of_children (self)
 Get the number of children at this node. More...
 
def set_child
 Adds a child to the node that will be added at the next open position. More...
 
def get_child
 Gets a child at particular index. More...
 
def get_data_structure_representation (self)
 Get the hierarchical JSON of the tree representation (internal use only) More...
 
- Public Member Functions inherited from bridges.element.Element
def get_data_structure_type (self)
 Get the data structure representation. More...
 
def __init__ (self, kwargs)
 
def value (self)
 Getter for the value this element is holding. More...
 
def value (self, val)
 Setter for the value of an element. More...
 
def identifier (self)
 Getter for the element identifier. More...
 
def identifier
 Setter for the element identifier. More...
 
def visualizer (self)
 Getter for the element visualizer. More...
 
def visualizer
 Setter function for this element visualizer. More...
 
def get_link_visualizer (self, el)
 
def set_link_visualizer (self, el)
 Setter for the link visualizer of this element. More...
 
def remove_link_visualizer (self, el)
 Deleter function for the lik visualizer of this element. More...
 
def label (self)
 Getter for the element's label. More...
 
def label (self, label)
 Setter for the element's label. More...
 
def size (self)
 Getter for the element's size. More...
 
def size (self, sz)
 Setter for the element's size. More...
 
def color (self)
 Getter for the element's color. More...
 
def color (self, col)
 Setter for the element's size. More...
 
def opacity (self)
 Getter for the element's opacity. More...
 
def opacity (self, op)
 Setter for the element's opacity. More...
 
def shape (self)
 Getter for the element's shape type. More...
 
def shape (self, shp)
 Setter for the element's shape. More...
 
def id (self)
 
def set_location (self, locX, locY)
 Setter for the element's location. More...
 
def get_locationX (self)
 Getter for the element's location in X. More...
 
def get_locationY (self)
 Getter for the element's location in Y. More...
 
def get_element_representation (self)
 Getter for the element's JSON representation (for internal use) More...
 
def get_link_representation (self, lv, src, dest)
 Getter for the JSON representation of the element's link (for internal use) More...
 

Public Attributes

 children
 
- Public Attributes inherited from bridges.element.Element
 color
 
 opacity
 

Static Public Attributes

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

Constructor & Destructor Documentation

◆ __init__()

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

Constructor for Tree Element.

Parameters
labelThe label for the tree element that shows in visualization
ethe generic object that the tree element will hold
leftthe tree element assigned to child 0
rightthe tree element assigned to child 1
Returns
None

Member Function Documentation

◆ add_child()

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

Adds a child to this parent node.

Parameters
childthe child node to add
Returns
None

◆ get_child()

def bridges.tree_element.TreeElement.get_child (   self,
  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()

def bridges.tree_element.TreeElement.get_data_structure_representation (   self,
  dict 
)

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

Returns
dict representing the data structures json

◆ get_data_structure_type()

def bridges.tree_element.TreeElement.get_data_structure_type (   self,
  str 
)

Gets the data structure type.

Returns
str representing the data structure type

◆ get_number_of_children()

def bridges.tree_element.TreeElement.get_number_of_children (   self,
  int 
)

Get the number of children at this node.

Returns
int representing the number of children

◆ set_child()

def bridges.tree_element.TreeElement.set_child (   self,
  index 
)

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

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

◆ CLOSE_CURLY

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

◆ CLOSE_PAREN

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

◆ COLON

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

◆ COMMA

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

◆ OPEN_BOX

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

◆ OPEN_CURLY

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

◆ OPEN_PAREN

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

◆ QUOTE

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

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