Skip to main content

A list-derived TREE data structure in Python 3

Project description

pyTree
======

A Python implementation of Tree data structure

#Examples

## Build up tree structure:
### Initialization case 1: Initialize as single node
root = Tree('Root')
child01 = Tree('C01')
child02 = Tree('C02')
child03 = Tree('C03')
child11 = Tree('C11')
child31 = Tree('C31')
child111 = Tree('C111')
child112 = Tree('C112')
#add children nodes
root.addChildren([child01, child02, child03])
child01.addChild(child11)
child03.addChild(child31)
child11.addChild(child111)
child11.addChild(child112)

#to print hierarchy tree structure
root.prettyTree()
#to print nested-list tree structure
#root.nestedTree()
#### Output:
Root
|___ C01
| |___ C11
| |___ C111
| |___ C112
|___ C02
|___ C03
| |___ C31

### Initialization case 2: Initialize with child
child31 = Tree('C31')
child03 = Tree('C03', child31 )

### Initialization case 3: Initialize with children
child01 = Tree('C01')
child02 = Tree('C02')
child03 = Tree('C03')
root = Tree('Root', [child01, child02, child03] )

## Methods
Methods
|___ addChild
|___ addChildren
|___ getParent
|___ getChild
|___ getChildren
|___ getNode
|___ delChild
|___ delNode
|___ getRoot
|___ isRoot
|___ isBranch
|___ prettyTree
|___ nestedTree

#LICENSING
Copyright 2012 Yoyo Zhou. Distributed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). See the `LICENSE` file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyTree-2.0.0.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file pyTree-2.0.0.tar.gz.

File metadata

  • Download URL: pyTree-2.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyTree-2.0.0.tar.gz
Algorithm Hash digest
SHA256 18267a9bd5abe697a05612d127008febfc66e531894bc89254c4c6a8d85663ad
MD5 172802a22fe0e00b3388d576c17e688a
BLAKE2b-256 e2eda0507be6ab4c363a349652f0b48983490856a07bb3d1a8c8b4889c3c4c96

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page