Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ignatiusmb/treevisualizer
Visualizer for binary tree data structure in Java.
https://github.com/ignatiusmb/treevisualizer
binary-search-tree data-structures java tree visualizer
Last synced: 25 days ago
JSON representation
Visualizer for binary tree data structure in Java.
- Host: GitHub
- URL: https://github.com/ignatiusmb/treevisualizer
- Owner: ignatiusmb
- License: unlicense
- Created: 2018-11-24T18:42:37.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-03T07:34:34.000Z (over 5 years ago)
- Last Synced: 2024-10-28T19:22:47.620Z (2 months ago)
- Topics: binary-search-tree, data-structures, java, tree, visualizer
- Language: Java
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TreeVisualizer
A simple program to print all the nodes in the tree with a beautiful output. Connected by lines with clear paths, it's nice to look and easy to debug a tree.## Getting Started
Download `TreeVisualizer.java` and put it in the same directory so you won't need to import anything## Usage
1. Put `TreeVisualizer.java` in the same directory with the `Node` file (to implement) and `Tree` file (to print)
2. Implements `Visualized` from `TreeVisualizer` to your `Node` class
3. Override `getLeft`, `getRight`, and `getValue` method with your values
```java
class Node implements TreeVisualizer.Visualized {
Node left, right;
String name;
...
@Override
public TreeVisualizer.Visualized getLeft() {
return this.left;
}@Override
public TreeVisualizer.Visualized getRight() {
return this.right;
}@Override
public String getValue() {
return this.name;
}
}
```
4. If your `Value` is other than a `String`, you need to modify it to return your data type
5. Use the provided `print` method and put the tree's `root` as the argument
```java
public class MyFile {
public static void main(String[] args) {
Tree tree = new Tree();
TreeVisualizer.print(tree.root);
}
}
```
**or**
```java
public class MyFile {
public static void main(String[] args) {
Tree tree = new Tree();
tree.print()
}
}class Tree {
Node root;
...
public void print() {
TreeVisualizer.print(this.root);
}
}
```---
TreeVisualizer is Unlicensed---