
How does the TreeElement<E> work?
TreeElement<E> is a superclass for tree structures and can represent tree structures
with arbitrary number of children at each node. The top node of the tree is
referred to as the "root".
In the example above, root node has 3 children, while its children has 2, 1 and 0 children
respectively. The childrent of a node is accessed by by set/getChild() methods, with an index
k, referring to its k'th child.
See also
This tutorial gives an introduction to the usage of trees. You can find the complete documentation of the features in the Doxygen documentation of the following classes and functions:
- TreeElement [Java] [C++] [Python]
- Element [Java] [C++] [Python]
- ElementVisualizer [Java] [C++] [Python]
- LinkVisualizer [Java] [C++] [Python]
- Color [Java] [C++] [Python]
TreeElement - BRIDGES Example
Example Details
- This example illustrates construction of a tree structure with a variable number of children.
- Children are added using the addChild() method, with ordering of children from left to right and accessed by an integer index (begining at 0).
- In the example, a small tree is built.
Here is a basic example code
Bridges Visualization
- Once all your code is in order, run your program.
- Assuming all your code is correct and it compiles correctly, a link to the Bridges website will be generated.
- Copy/paste this link into your favorite browser to view a visualization of the data structure you’ve just created.
- It should look something like this:
Styling trees in BRIDGES
You can style the nodes of the trees, and and links of trees in BRIDGES. This uses the ElementVisualizer and the LinkVisualizer classes. These classes enable you to set the color, size, and labels on the nodes and links of the tree.
Here is the same example with some visual attributes set.
Here is the final code:
Bridges Visualization
- Once all your code is in order, run your program.
- Assuming all your code is correct and it compiles correctly, a link to the Bridges website will be generated.
- Copy/paste this link into your favorite browser to view a visualization of the data structure you’ve just created.
- It should look something like this:
Well done! You’ve just created your Bridges Tree project!