GithubHelp home page GithubHelp logo

ignatiusmb / treevisualizer Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 10 KB

Visualizer for binary tree data structure in Java.

License: The Unlicense

Java 100.00%
java tree visualizer data-structures binary-search-tree

treevisualizer's Introduction

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
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;
  }
}
  1. If your Value is other than a String, you need to modify it to return your data type
  2. Use the provided print method and put the tree's root as the argument
public class MyFile {
  public static void main(String[] args) {
    Tree tree = new Tree();
    TreeVisualizer.print(tree.root);
  }
}

or

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


ignatiusmb.io · GitHub · GitLab

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.