treestructure


Nametreestructure JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/Musicmathstudio/treeStructure
SummaryTree Structure is a module that implements some common trees in data structure.
upload_time2023-09-05 14:46:56
maintainer
docs_urlNone
authorTony Chiu
requires_python>=3
license
keywords tree structure data structure binary search tree binary heap
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tree Structure

![Pypi link](https://img.shields.io/pypi/v/treestructure.svg?style=flat-square)

Tree Structure is a module that implements some common trees in data structure.

## Quick Start

There are two basic components in each type of tree structure: **Node** and **Tree**.  
Each node has two basic attributes: **order** and **value**.  
Order is the key to construct the tree structure. Default order is current timestamp.  
Value can be anything you want to store. Default value is None.

``` python
>>> import treestructure
>>> node = treestructure.BinaryNode(35, 'Stevie Wonder') # Create node
>>> node.order
35
>>> node.value
'Stevie Wonder'
```

Insert node into tree to build the tree structure.  
Use package() to check the tree structure.
It's better using package() with [pprint](https://docs.python.org/3/library/pprint.html) module.

``` python
>>> import pprint
>>> tree = treestructure.BinarySearchTree(node) # Create tree
>>> tree.insertNode(treestructure.BinaryNode(45, 'Ray Charles')) # Insert node
>>> tree.insertNode(treestructure.BinaryNode(25, 'Lionel Richie')) # Insert node
>>> pprint.pprint(tree.package(), sort_dicts=False) # Display tree
{'order': 35,
 'value': 'Stevie Wonder',
 'leftChildNode': {'order': 25,
                   'value': 'Lionel Richie',
                   'leftChildNode': None,
                   'rightChildNode': None},
 'rightChildNode': {'order': 45,
                    'value': 'Ray Charles',
                    'leftChildNode': None,
                    'rightChildNode': None}}
```

Delete node by specific order.

``` python
>>> delNode = tree.deleteNode(35) # Delete node
>>> pprint.pprint(delNode.package(), sort_dicts=False) # Display node
{'order': 35,
 'value': 'Stevie Wonder',
 'leftChildNode': {},
 'rightChildNode': {},
 'parentNode': {}}
>>> pprint.pprint(tree.package(), sort_dicts=False) # Display tree
{'order': 25,
 'value': 'Lionel Richie',
 'leftChildNode': None,
 'rightChildNode': {'order': 45,
                    'value': 'Ray Charles',
                    'leftChildNode': None,
                    'rightChildNode': None}}
```

## Contents

- [Binary Node](https://github.com/Musicmathstudio/treeStructure/blob/main/doc/binaryNode.md)
- [Binary Search Tree](https://github.com/Musicmathstudio/treeStructure/blob/main/doc/bst.md)
- [Binary Heap](https://github.com/Musicmathstudio/treeStructure/blob/main/doc/heap.md)
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Musicmathstudio/treeStructure",
    "name": "treestructure",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "tree structure,data structure,binary search tree,binary heap",
    "author": "Tony Chiu",
    "author_email": "pi3141592676@yahoo.com.tw",
    "download_url": "https://files.pythonhosted.org/packages/9c/54/fef8c2bb4d31f3a9fe081e2eba10011917c5477833559276e0b49686613e/treestructure-1.1.0.tar.gz",
    "platform": null,
    "description": "# Tree Structure\n\n![Pypi link](https://img.shields.io/pypi/v/treestructure.svg?style=flat-square)\n\nTree Structure is a module that implements some common trees in data structure.\n\n## Quick Start\n\nThere are two basic components in each type of tree structure: **Node** and **Tree**.  \nEach node has two basic attributes: **order** and **value**.  \nOrder is the key to construct the tree structure. Default order is current timestamp.  \nValue can be anything you want to store. Default value is None.\n\n``` python\n>>> import treestructure\n>>> node = treestructure.BinaryNode(35, 'Stevie Wonder') # Create node\n>>> node.order\n35\n>>> node.value\n'Stevie Wonder'\n```\n\nInsert node into tree to build the tree structure.  \nUse package() to check the tree structure.\nIt's better using package() with [pprint](https://docs.python.org/3/library/pprint.html) module.\n\n``` python\n>>> import pprint\n>>> tree = treestructure.BinarySearchTree(node) # Create tree\n>>> tree.insertNode(treestructure.BinaryNode(45, 'Ray Charles')) # Insert node\n>>> tree.insertNode(treestructure.BinaryNode(25, 'Lionel Richie')) # Insert node\n>>> pprint.pprint(tree.package(), sort_dicts=False) # Display tree\n{'order': 35,\n 'value': 'Stevie Wonder',\n 'leftChildNode': {'order': 25,\n                   'value': 'Lionel Richie',\n                   'leftChildNode': None,\n                   'rightChildNode': None},\n 'rightChildNode': {'order': 45,\n                    'value': 'Ray Charles',\n                    'leftChildNode': None,\n                    'rightChildNode': None}}\n```\n\nDelete node by specific order.\n\n``` python\n>>> delNode = tree.deleteNode(35) # Delete node\n>>> pprint.pprint(delNode.package(), sort_dicts=False) # Display node\n{'order': 35,\n 'value': 'Stevie Wonder',\n 'leftChildNode': {},\n 'rightChildNode': {},\n 'parentNode': {}}\n>>> pprint.pprint(tree.package(), sort_dicts=False) # Display tree\n{'order': 25,\n 'value': 'Lionel Richie',\n 'leftChildNode': None,\n 'rightChildNode': {'order': 45,\n                    'value': 'Ray Charles',\n                    'leftChildNode': None,\n                    'rightChildNode': None}}\n```\n\n## Contents\n\n- [Binary Node](https://github.com/Musicmathstudio/treeStructure/blob/main/doc/binaryNode.md)\n- [Binary Search Tree](https://github.com/Musicmathstudio/treeStructure/blob/main/doc/bst.md)\n- [Binary Heap](https://github.com/Musicmathstudio/treeStructure/blob/main/doc/heap.md)",
    "bugtrack_url": null,
    "license": "",
    "summary": "Tree Structure is a module that implements some common trees in data structure.",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/Musicmathstudio/treeStructure"
    },
    "split_keywords": [
        "tree structure",
        "data structure",
        "binary search tree",
        "binary heap"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c54fef8c2bb4d31f3a9fe081e2eba10011917c5477833559276e0b49686613e",
                "md5": "755c04ed6d1f5fb36ba51449b9104e09",
                "sha256": "ab5b7b48efaf7bc320cd66c9f9cb3ef8528a59fab8820267b50ed751f6532142"
            },
            "downloads": -1,
            "filename": "treestructure-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "755c04ed6d1f5fb36ba51449b9104e09",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 13704,
            "upload_time": "2023-09-05T14:46:56",
            "upload_time_iso_8601": "2023-09-05T14:46:56.556370Z",
            "url": "https://files.pythonhosted.org/packages/9c/54/fef8c2bb4d31f3a9fe081e2eba10011917c5477833559276e0b49686613e/treestructure-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-05 14:46:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Musicmathstudio",
    "github_project": "treeStructure",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "treestructure"
}
        
Elapsed time: 0.36776s