Skip to content

tungndtt/beautiful_binary_tree_drawing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Beautiful binary tree drawing

This piece of code helps you to draw the binary tree beautifully.

DrawFactory provides the drawer, which displays your tree in following formats :

Tree Format

By set Mode to DrawMode.TREE

  • Displaying the binary tree in tree-format. The logic would take into account the length of your value in the tree node.

    Besides, you can also modify the distance between 2 stages as well as the minimal indent-distance between 2 tree nodes.

  • Here is the demo

Directory Format

By set Mode to DrawMode.DIRECTORY

  • Displaying the binary tree in directory-format.

    You can modyfy the distance between 2 stages as well as the horizontal indent-distance

  • Here is the demo

Hierarchy Format

By set Mode to DrawMode.HIERARCHY

  • Displaying the binary tree in hierarchy-format

    You can modify minimal indent-distance between tree nodes.

  • Here is the demo


Parsing tree from file

In addition: If you are tired of constructing the tree node-instances by hand. You can provide your tree as following rules to get the tree

  • Line format:   {position} , {node's value} with position :=

    • t (root)
    • r (right)
    • l (left)

    You can look into this Example

  • Just read text file (.txt-format)

  • One node information per line

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages