GithubHelp home page GithubHelp logo

bosque's Introduction

Bosque

This program has intent to draw binary search trees using LaTeX. The application receives one or more trees in preorder format as parameter and draw this tree with LaTeX resulting in a SVG image file.

Dependencies

If you are using Ubuntu Linux you will need this following packages:

Otherwise you have to install the latex base texlive-base, the tikzpicture package and pdf2svg.

Installing

In order to install you will need to compile the tree generator. Go to the source directory.

$ cd drawbstree

Type make to compile the program.

$ make

Type make install as root user to install the application.

$ sudo make install

Using

Basic

After installed the application will have a program called desenhar. You can type it with the desired tree in preorder. For instance:

$ desenhar 5 3 1 4 6

Specifying the output file:

$ desenhar -o out.svg 5 3 1 4 6

More than one tree

You can draw more than one tree. They will be converted all in the same image since they fit in one page. You should identify each new tree with a dot at start of it.

$ desenhar 15 5 3 12 10 6 7 13 16 20 18 23 . 15 6 3 12 10 7 13 16 20 18 23

Huffman

Bosque is starting to support huffman coding trees. It is slightly different from the default method. To draw a huffman coding tree you should pass the option --huffman to desenhar. This will make Bosque read the tree from the standard input (the terminal, for instance). The format to draw a huffman coding tree is, for each node a integer value indicating the position in the binary tree and the string of node. A node that is a extension of other should start with character '/', and a node that has space, use '~' instead. For instance, if you want a tree to compress banana word, you will pass to desenhar something like this:

4 /:6
2 /:3
1 b:1
3 n:2
5 a:3

Drawing the banana tree:

echo "4 /:6 2 /:3 1 b:1 3 n:2 5 a:3" | desenhar --huffman

See the wiki to see how this tree will look like!

Integrating

Using bash you can set up your exercise or testing application to print out the tree in preorder. And with a pipe we can redirect the application output as desenhar execution parameters.

C

$ ./binary_tree | xargs desenhar

Java

$ java tree/Main | xargs desenhar

Ruby

$ ruby tree_test.rb | xargs desenhar

Also, you can use tee to get your application output before redirect to desenhar:

$ ./my_avl_tree | tee | xargs desenhar -o output.svg

This example also showed how define the output file to the trees.

bosque's People

Contributors

paulourio avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

rymines

bosque's Issues

Problem to draw more than one three in Red-Black mode

To construct more than one tree, instead emit "." it is being needed to emit "0 .". The problem is on the reading from standard input, when we try to get a number everytime, and the point is treated as a number.

PS: Didn't check for huffman, but might be problem as well.

Unsafe reading

When huffman coding tree is select, the input comes from standard input. We are using 'scanf' to read the tree, which is very unsafe, and any problem in input format cause the program to wait forever.

Area Limit

Set a sane area limit to the trees. Currently the values were set deliberately without even a second of thinking.

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.