drawtree

Draw binary tree in plain text

https://github.com/msbanik/drawtree

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 3 committers (66.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.1%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

Draw binary tree in plain text

Basic Info
  • Host: GitHub
  • Owner: msbanik
  • Language: Python
  • Default Branch: master
  • Size: 23.4 KB
Statistics
  • Stars: 68
  • Watchers: 2
  • Forks: 15
  • Open Issues: 6
  • Releases: 0
Created almost 11 years ago · Last pushed over 2 years ago
Metadata Files
Readme

README.rst

drawtree
========

.. image:: https://img.shields.io/pypi/v/drawtree.svg?style=flat-square&label=latest%20version
    :target: https://pypi.python.org/pypi/drawtree
    :alt: Latest PyPI version


Draw binary tree in plain text

Usage
-----
Draw tree from level order traversal, '#' signifies a path terminator where no node exists below.

.. code-block:: python

    from drawtree import draw_level_order
    draw_level_order('{3,9,20,#,#,15,7}')

::

      3
     / \
    9  20
       / \
      15  7

Draw random binary search tree

.. code-block:: python

    from drawtree import draw_random_bst
    draw_random_bst(10)

::

        64
        / \
       /   \
      4    66
       \     \
       37    70
       / \
      8  51
     / \
    6  12
         \
         21

Draw binary search tree from integer array

.. code-block:: python

    from drawtree import draw_bst
    nums = [55, 30, 10, 5, 2, 20, 15, 25, 40, 35, 70, 60, 80, 75, 95]
    draw_bst(nums)

::

                 55
                 / \
                /   \
               /     \
              /       \
             30       70
            / \       / \
           /   \     /   \
          /     \   60   80
         10     40       / \
        / \     /       /   \
       /   \   35      75   95
      5    20
     /     / \
    2     /   \
         15   25


Command line
------------

Flags:
 -p, --preorder    interpet sequence as preorder    
 -b, --balanced    auto balance bst
 -l, --level-order interpet sequence as level-order

Print a bst:

.. code-block:: bash

    $ bst 10 5 8 4 6 
    $ bst nodes.txt
    $ echo "colin eric dave" | bst
    $ cat nodes.txt | sort | uniq | bst

Print a balanced bst:

.. code-block:: bash

    $ bst -b 10 5 6 9 3
    $ bst -b nodes.txt
    $ bst -b < nodes.txt

Print a bst from a preorder expression:

.. code-block:: bash

    $ bst -p dave colin dan
    $ echo "1 2 3 4 5" | bst -p
    $ bst -p nodes.txt  

Print a binary tree from a level order expression:

.. code-block:: bash

    $ bst -l [4,#,7,5,9,#]   (leetcode format)
    $ bst -l {4 # 7 5} 

Print a random bst:

.. code-block:: bash

    $ bst           (random bst of 10 nodes)
    $ bst 5         (random bst of 5 nodes)
    $ bst -b 7      (random balanced bst of 7 nodes)


Installation
------------
To install drawtree, simply:

.. code-block:: bash

    $ pip install drawtree


Licence
-------
MIT

Reference
---------
`Draw tree `_

Authors
-------

`drawtree` was written by `Madhusudan Banik `_.

Owner

  • Name: Madhusudan Banik
  • Login: msbanik
  • Kind: user
  • Location: Seattle, WA

Software Engineer @Microsoft , former @Nokia

GitHub Events

Total
Last Year

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 11
  • Total Committers: 3
  • Avg Commits per committer: 3.667
  • Development Distribution Score (DDS): 0.364
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Madhusudan Banik m****k@g****m 7
joncrall c****j@r****u 3
Eric Pratt e****t@m****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 6
  • Total pull requests: 4
  • Average time to close issues: 22 days
  • Average time to close pull requests: 2 months
  • Total issue authors: 6
  • Total pull request authors: 4
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • AlJohri (1)
  • deb17 (1)
  • greekatos (1)
  • 01joy (1)
  • zodman (1)
  • hotea (1)
Pull Request Authors
  • leoxanigm (2)
  • Erotemic (1)
  • Pratted (1)
  • renxida (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 21 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 2
  • Total versions: 2
  • Total maintainers: 1
pypi.org: drawtree

Draw binary tree in plain text

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 21 Last month
Rankings
Stargazers count: 8.4%
Forks count: 9.3%
Dependent packages count: 10.0%
Average: 10.8%
Dependent repos count: 11.6%
Downloads: 14.5%
Maintainers (1)
Last synced: 11 months ago

Dependencies

setup.py pypi